从数据框中的单个列获取文本数据
obtaining textual data from a single column in dataframe
我只想将我的数据框的一个特定列(即第 3 列 C)作为文本读取,并创建一个词云。让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 <- 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)
我只想将我的数据框的一个特定列(即第 3 列 C)作为文本读取,并创建一个词云。让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 <- 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)