r - Why does this code double transpose a vector - is this a noop? -


i have legacy r code does:

b = t(a) c = t(b) 

what code do? looks noop me. a vector constructed c(1:20).

edit: bonus points on how better.

have @ structure using str:

> str(a); str(b); str(c)  int [1:20] 1 2 3 4 5 6 7 8 9 10 ...  int [1, 1:20] 1 2 3 4 5 6 7 8 9 10 ...  int [1:20, 1] 1 2 3 4 5 6 7 8 9 10 ... 

the final transpose operation sends vector a matrix 20 rows , 1 column. equivalent to:

c <- as.matrix(c(1:20)) 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -