Reputation: 965
This may be basic but I want to take elements of a matrix row wise and puts them in a column vector. How to do that?
#A matrix
BETA <- matrix(c(0.215, 0.031, 0.003, 0.323), byrow = TRUE, ncol = 2)
#I want to achieve this:
0.215
0.031
0.003
0.323
Upvotes: 0
Views: 41
Reputation: 1595
I am assuming you want to get a numeric
class. Here is how to do it.
BETA <-matrix(c(0.215, 0.031, 0.003, 0.323), byrow = TRUE, ncol = 2)
BETA_column = as.numeric( t(BETA) )
BETA_column
#> [1] 0.215 0.031 0.003 0.323
Created on 2021-02-19 by the reprex package (v1.0.0)
Upvotes: 1