繁体   English   中英

R:将字符转换为具有一列且行数与字符中的单词数相同的向量

[英]R: convert character into vector with one column and with number of rows the same as the number of words in character

我想知道是否可以创建一个向量,而仅将其一列和行数与输入字符串中的单词数相同。 例如,对于字符串

> topicsLists 
[1] "nice"       "experience"

我想要一个像这样的向量:

[1] "nice"      
[2] "experience"

任何帮助深表感谢!

向量没有列。 但是您可以做的是创建一个单列matrix

> topicsLists <- c("nice", "experience")
> as.matrix(topicsLists)
#      [,1]        
# [1,] "nice"      
# [2,] "experience"

或者,您也可以为相同的结果做matrix(topicsLists)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM