R reshape2’缺少聚合功能:默认为’
发布时间:2020-12-13 20:24:30 所属栏目:百科 来源:网络整理
导读:参见英文答案 dcast restructuring from long to wide format not working1 我在SO上看到了这个重塑2次,但没有看到解决我的特殊问题; 我有一个这样的数据集 head(data)student test scoreAdam Exam1 80Adam Exam2 90John Exam1 70John Exam2 60 我试图把它变
参见英文答案 >
dcast restructuring from long to wide format not working1
我在SO上看到了这个重塑2次,但没有看到解决我的特殊问题; 我有一个这样的数据集 head(data) student test score Adam Exam1 80 Adam Exam2 90 John Exam1 70 John Exam2 60 我试图把它变成一个宽广的格式,看起来像这样; Student Exam1 Exam2 ........ ExamX Adam 80 90 John 70 60 使用; dcast(data,student~test,value.var='score') 但数据最终看起来像这样的东西; Student Exam1 Exam2 Adam 0 0 John 0 1 有这个错误; Aggregation function missing: defaulting to length 任何想法为什么它将所有这些值改为(0或1)?
感谢@akrun谁指出了.
那么你的数据有很大的重复行,看起来像这样: student test score Adam Exam1 80 Adam Exam1 85 Adam Exam2 90 John Exam1 70 John Exam2 60 或者像这样: student class test score Adam Biology Exam1 80 Adam Theology Exam1 85 Adam Theology Exam2 90 John Biology Exam1 70 John Theology Exam2 60 当你像这样投掷它:dcast(数据,学生类?test,value.var =’score’) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |