[英]From data.frame to matrix
I knew to R; 我对R知道; I have a data fame with 8 variables (columns) and 587632 observation (rows).
我有8个变量(列)和587632个观察值(行)的数据结构。
AggregateActivities <- data.frame(sleep, eating, personalcare, cooking, houseclean, laundry, ironing, travel)
I would like to convert AggregateActivities the data frame into a matrix such as 我想将AggregateActivities数据框转换为矩阵,例如
dat <- matrix(c( values from AggregateActivities) nrow=587632, ncol=8, byrow=TRUE)
Can somebody help me wit this please 有人可以帮我这个机智吗
Just change this: 只需更改此:
AggregateActivities <- data.frame(sleep, eating, personalcare)
To This: 为此:
AggregateActivities <- matrix(data.frame(sleep, eating, personalcare))
函数data.matrix是专门为此目的而构建的>
AggMat <- data.matrix( AggregateActivities )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.