【发布时间】:2018-12-07 08:16:42
【问题描述】:
我在将矢量类型对象转换为字符串时遇到了一些问题。
我试过了:
x <- paste(x, sep = " ", collapse = NULL)
和各种不同类型的粘贴函数,但is.String(x) 的返回仍然是FALSE,is.vector 的返回仍然是TRUE。下面是我的代码:
bio_sentences <- sent_detect(bio) #Using openNLP to get the sentences from a bio
is.vector(bio_sentences) #Returns TRUE
sentisimo <- bio_sentences[1] #Needed as I want to do analysis sentence by sentence
sentisimo <- paste(sentisimo, sep = " ", collapse = NULL)
as.character(sentisimo)
is.vector(sentisimo) #Returns TRUE
is.character(sentisimo) #Returns TRUE
sentisimo <- paste(bio_sentences[1], sep = "")
as.String(sentisimo)
is.String(sentisimo) #Returns FALSE
str(sentisimo) Returns chr "1st sentence of the bio"
dput(sentisimo) #Returns "Dennis Muilenburg is chairman of the board, president and chief executive officer of The Boeing Company."
如果有人能帮我将向量的元素转换为字符串,我将不胜感激。
【问题讨论】:
-
你从哪个库获得
is.String -
请显示向量和你想要的输出。
-
@A. Suliman 这个包叫做“NLP”
标签: r string vector type-conversion opennlp