快速创建data.frame

时间:2015-08-16 09:13:39

标签: r dataframe

有没有办法比我下面制作的数据框更快或更智能?

df <- data.frame(ID = rep(c("WT", "KO"), each = 4),
                 Time = rep(c("A", "B", "C", "D"), times = 2),
                 replicate(5,sample(0:100,8,rep=TRUE)))

colnames(df)<-c("ID", "Time", c("a", "b", "c", "d", "e"))

data.frame仍然应该是这样的

df
ID Time  a  b  c  d  e
WT    A 28 56 50 60 15
WT    B 54 77 11 67 34
WT    C 53  8 87 62 55
WT    D 30 73 47 82  1
KO    A 24 83 14 17 36
KO    B 91 83 72 41  4
KO    C 79 17 76 21 54
KO    D 41 40 77 49 92

由于

0 个答案:

没有答案