R中的转置函数不是转置 [英] Transpose Function in R is not transposing
本文介绍了R中的转置函数不是转置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试在 R 中转置向量然后命名.
Trying to transpose a vector in R and then name it.
我创建了一个向量,v
如下:
I created a vector, v
as follows:
v<-c(1,2,3,4)
但是当我尝试转置为:
t(v)
它给出了输出:
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.
推荐答案
#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
这篇关于R中的转置函数不是转置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文