> mydata
ID Time X1 X2
1 1 1 5 6
2 1 2 3 5
3 2 1 6 1
4 2 2 2 4
> library(plyr)
> library(reshape)
载入程辑包:'reshape'
The following object(s) are masked from 'package:plyr':
round_any
> md<-melt(mydata,id=(c("ID","Time")),na.rm=TRUE)
> md
ID Time variable value
1 1 1 X1 5
2 1 2 X1 3
3 2 1 X1 6
4 2 2 X1 2
5 1 1 X2 6
6 1 2 X2 5
7 2 1 X2 1
8 2 2 X2 4
> cast(md,ID~variable,mean)
错误于data.frame(`NA` = c(NA_real_, NA_real_, NA_real_, NA_real_), :
arguments imply differing number of rows: 4, 0
请教大神,问题出在哪儿了?
|