Transpose Function in R is not transposing

元气小坏坏 提交于 2019-12-20 02:15:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!