用向量列方式填充数据帧

时间:2018-05-02 23:08:00

标签: r

我有以下矢量:

vec <-  c( 1.5024902,   0.9051428,   1.0000000,   2.4813651,0.3804750,   0.5399517,1.0000000,1.6967545,1.4096899, 2.5858617, 1.0000000,   1.9426744,  -0.4634633,   0.8577193, 1.0000000, 0.2998213,2.0853813,   0.6517149,   1.0000000,   0.2981432,   0.9345624,   
0.4302179,   1.0000000,  -1.0631703,-18.5043500, -22.8724403, -Inf, -12.1109292)

我想填充4 x 7数据帧,但是按列添加值。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

mat <- as.data.frame(matrix(data = vec, nrow = 4, ncol = 7))