Workhorse
Workhorse

Reputation: 1560

Fill Dataframe With Vector Column-wise

I have the following vector:

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)

I would like to populate a 4 x 7 dataframe, but add the values by column. How can I do this?

Upvotes: 2

Views: 1733

Answers (1)

nsinghphd
nsinghphd

Reputation: 2022

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

Upvotes: 2

Related Questions