Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将矩阵作为R中data.frame的元素?_R_Dataframe - Fatal编程技术网

如何将矩阵作为R中data.frame的元素?

如何将矩阵作为R中data.frame的元素?,r,dataframe,R,Dataframe,我在R中有一个数据帧,如下所示: a b c out1 out2 0 1 0 NA NA 1 0 1 NA NA 1 1 0 NA NA DF <- data.frame(a = c(0,1,1), b= c(1,0,1), c = c(0,1,0), out1=NA, out2=NA) a b c out 1 ou

我在R中有一个数据帧,如下所示:

a      b      c      out1      out2
0      1      0      NA        NA
1      0      1      NA        NA
1      1      0      NA        NA

DF <- data.frame(a = c(0,1,1), b= c(1,0,1), c = c(0,1,0), out1=NA, out2=NA)
a b c out 1 out 2
0110NA
101NA
101NA

DF我们可以将
矩阵
包装在
列表
中,然后将其分配给单元格

dataframe$out[1] <- list(matrixObj)

dataframe$out[1]您可以用
list
将其包装起来,然后编写,即
dataframe$out[1]工作得很好!非常感谢。