use*_*507 6 merge r text-mining
我有一个文本数据框,如下所示.
> nrow(gettext.df)
[1] 3
> gettext.df
gettext
1 hello,
2 Good to hear back from you.
3 I've currently written an application and I'm happy about it
Run Code Online (Sandbox Code Playgroud)
我想将这些文本数据合并到一个单元格中(进行情感分析),如下所示
> gettext.df
gettext
1 hello, Good to hear back from you. I've currently written an application and I'm happy about it
Run Code Online (Sandbox Code Playgroud)
所以我使用下面的代码折叠了单元格
paste(gettext.df, collapse =" ")
Run Code Online (Sandbox Code Playgroud)
但似乎它使这些文本数据成为一个块(作为一个单词),所以我无法逐字扫描句子.
有没有什么方法可以将这些句子合并为一个句子集合,而不是将其转化为一个大字块?
Sve*_*ein 14
在使用之前,您必须将数据框列转换为字符向量paste.
paste(unlist(gettext.df), collapse =" ")
Run Code Online (Sandbox Code Playgroud)
返回:
[1] "hello, Good to hear back from you. I've currently written an application and I'm happy about it"
Run Code Online (Sandbox Code Playgroud)