问题
Trying to transpose a vector in R and then name it.
I created a vector, v
as follows:
v<-c(1,2,3,4)
But when I try to transpose as:
t(v)
It gives the output:
t(v)
[,1] [,2] [,3] [,4]
[1,] 1 2 3 4
I know I can create a matrix or define a vector the other way, but I think the bigger issue is why transpose itself is not working. I do not have any packages installed or things like that.
回答1:
#Create data
v<-c(1,2,3,4)
#In addition to the answers presented prior to mine, you could do this.
t(t(v))
[,1]
[1,] 1
[2,] 2
[3,] 3
[4,] 4
来源:https://stackoverflow.com/questions/51201856/transpose-function-in-r-is-not-transposing