R 在主题内重新排序数据框
我有一个大型数据集,可以跨学科进行重复评估。我如何从:
subj, assessment, test1, test2
A, 1, 10, 20
A, 2, 12, 13
A, 3, 11, 12
B, 1, 14, 14
B, 2, 13, 12
到:
subj, test1_1, test1_2, test1_3
A, 10, 12, 11
B, 14, 13
谢谢,
乔恩
I have a large dataset with repeat assessment across subjects. How do I go from:
subj, assessment, test1, test2
A, 1, 10, 20
A, 2, 12, 13
A, 3, 11, 12
B, 1, 14, 14
B, 2, 13, 12
To:
subj, test1_1, test1_2, test1_3
A, 10, 12, 11
B, 14, 13
Thanks,
Jon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
reshape 函数(在 stats 中)相当容易地完成此操作:
或者只是获取 test1 的结果:
The reshape function (in stats) does this fairly easily:
Or to just get the results for test1:
您可以使用 hadley 出色的 reshape/reshape2 包轻松完成此任务。这是带您找到所需内容的代码,
请告诉我这是否适合您。
you can easily accomplish this using the excellent reshape/ reshape2 package by hadley. here is the code to take you to what you need
let me know if this works for you.