从dataframe中的单个列获取文本数据

从dataframe中的单个列获取文本数据,r,readline,quanteda,R,Readline,Quanteda,我只想以文本形式读取数据框的一个特定列,即第三列C,并创建一个word cloud。让df= A B C 1 2 sheep 2 2 sheep 3 4 goat 4 5 camel 5 2 camel 6 1 camel 我试图从readLines(df$C)读取行,但出现以下错误: Error in readLines(df$C) : 'con' is not a connection df% dfm()%>% textplot\u wordcloud(最小计数=1) df%

我只想以文本形式读取数据框的一个特定列,即第三列C,并创建一个word cloud。让
df=

A B C
1 2 sheep
2 2 sheep
3 4 goat
4 5 camel
5 2 camel
6 1 camel
我试图从
readLines(df$C)
读取行,但出现以下错误:

 Error in readLines(df$C) : 
  'con' is not a connection
df%
dfm()%>%
textplot\u wordcloud(最小计数=1)

df%
dfm()%>%
textplot\u wordcloud(最小计数=1)

你不是只想要
df$C
?如果你已经有了这个数据帧,
df$C
是否没有得到你想要的?
readLines
用于从文件中读取信息行。如果我理解正确,您已经有了一个数据框,因此您不需要在会话中读取任何内容。您不只是想要
df$C
?如果您已经有了它作为数据框,那么
df$C
是否没有得到您想要的内容?
readLines
用于从文件中读取信息行。如果我理解正确的话,你已经有了一个数据框,因此你不需要仅仅出于好奇而在你的会话中阅读任何内容,有没有一种简单的方法来删除所分析文本中的标点符号和停止单词?是的,在
dfm()
调用您可以将参数传递给
tokens()
-请参阅
?tokens
-其中一个
dfm()
参数是
remove
(用于删除停止字)。出于好奇,是否有一种简单的方法可以删除所分析文本中的标点符号和停止字?是的,请参阅
dfm()
调用您可以将参数传递给
tokens()
-请参阅
?tokens
-其中一个
dfm()
参数是
remove
(用于删除停止字)。
df <- read.table(textConnection("A B C
1 2 sheep
2 2 sheep
3 4 goat
4 5 camel
5 2 camel
6 1 camel"), header = TRUE, stringsAsFactors = FALSE)

library("quanteda")
## Package version: 1.3.0

corpus(df, text_field = "C") %>%
    dfm() %>%
    textplot_wordcloud(min_count = 1)