R:cast的错误消息;未实现类型';列表';在';listgreater";

R:cast的错误消息;未实现类型';列表';在';listgreater";,r,casting,R,Casting,使用以下命令(x是一个包含3列a、B和C的表) 出现以下错误: Using C as value column. Use the value argument to cast to override this choice Error in order(A = list("xxx", : unimplemented type 'list' in 'listgreater' 这意味着什么?如何解决 我想这可能是由于数据帧的数据格式(如果我错了,请纠正我)。我用str命令测试了表x和y

使用以下命令(x是一个包含3列a、B和C的表)

出现以下错误:

Using C as value column.  Use the value argument to cast to override this choice
Error in order(A = list("xxx",  : 
  unimplemented type 'list' in 'listgreater'
这意味着什么?如何解决


我想这可能是由于数据帧的数据格式(如果我错了,请纠正我)。我用str命令测试了表x和y的格式

str(x) returns
$ A: List of 6
..$ : chr "xxx"
....
$ B:chr "yyy" "yy2" ....
...
$ C: List of 6
..$ : num 22.....
...
对于另一个列为de和F的表y,运行cast命令时不会显示错误消息

str(y) shows that all D E F columns are Factor w/ 6 levels....

如何使包含数据帧x的list和num的cast工作?

我认为第一个data.frame不是data.frame,而是list。转换为data.frame将解决这个问题。使用:

x <- as.data.frame(x)
library(reshape)
cast(x, A~B)
x使用

df <- as.data.frame(lapply(df, unlist))

df谢谢你,我试了一个,但是str(x)的结果在做了“x lol,HTH”后是一样的。下次评论我的anwser;-),所以我知道有人对它发表了评论。你能发布一些关于x的更多信息吗?一个可复制的例子会很好。尝试使用dput(x)。
df <- as.data.frame(lapply(df, unlist))