我有一个如下所示的数据框。
"id" "question" "response" "suite"
1 "x" "a" "1"
2 "y" "b" "1"
3 "x" "c" "1"
4 "y" "d" "1"
5 "x" "e" "2"
6 "y" "f" "2"
到目前为止,Dcast(在 reshape2 中)似乎是我最好的选择。
result <- dcast(df, id + suite ~ question, value.var = "response")
虽然我最终得到了这个;
"id" "suite" "x" "y"
1 "1" "1" "1"
2 "1" "1" "1"
3 "1" "1" "1"
4 "1" "1" "1"
5 "2" "1" "1"
6 "2" "1" "1"
伴随着错误;
Aggregation function missing: defaulting to length(response)
如何在不丢失“响应”列中的字符串的情况下获得第二种格式?