如何在给定一组向量的情况下创建新数据集?

时间:2009-10-31 19:57:30

标签: r dataset vector

在R中是否有办法建立一个新的数据集,该数据集由一组给定的向量组成 - median1,median2,median3,median4--它们是来自先前数据集的中值向量?

median1 = apply(s[,c("A1","B1","C1","D1","E1","F1","G1","H1","I1")],1,median)
median2 = apply(s[,c("A2","B2","C2","D2","E2","F2","G2","H2","I2")],1,median)
median3 = apply(s[,c("A3","B3","C3","D3","E3","F3","G3","H3","I3")],1,median)
median4 = apply(s[,c("A4","B4","C4","D4","E4","F4","G4","H4","I4")],1,median)

plot(median1,median2, pch = ".")

1 个答案:

答案 0 :(得分:12)

你是什么意思“建立一个新的数据集”?喜欢这个?

s2 <- data.frame(median1, median2, median3, median4)

或者使用cbind:

s2 <- cbind(median1, median2, median3, median4)