I have some legacy R code that does:
b = t(a)
c = t(b)
What does this code do? Looks like a noop to me. a
is a vector constructed by c(1:20)
.
Edit: bonus points on how to do this better.
Have a look at the 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 the vector a
to a matrix with 20 rows and 1 column. Equivalent to:
c <- as.matrix(c(1:20))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With