tidytext错误(is_corpus_df(corpus)中的错误:ncol(corpus)>=2不正确)
我试图做一些基本的文本分析。安装“tidytext”软件包后,我试图取消对数据帧的测试,但一直出现错误。我假设我丢失了一些软件包,但我不确定如何找出哪一个。如有任何建议,我们将不胜感激 您的列文本实际上是dataframe text_df中的一个dataframe,因此您试图将非最新标记应用于dataframe,但只有将其应用于原子向量字符、整数、双精度、逻辑等时,它才会起作用 要解决此问题,您可以执行以下操作:tidytext错误(is_corpus_df(corpus)中的错误:ncol(corpus)>=2不正确),r,tidytext,R,Tidytext,我试图做一些基本的文本分析。安装“tidytext”软件包后,我试图取消对数据帧的测试,但一直出现错误。我假设我丢失了一些软件包,但我不确定如何找出哪一个。如有任何建议,我们将不胜感激 您的列文本实际上是dataframe text_df中的一个dataframe,因此您试图将非最新标记应用于dataframe,但只有将其应用于原子向量字符、整数、双精度、逻辑等时,它才会起作用 要解决此问题,您可以执行以下操作: library(dplyr) library(tidytext) text_df
library(dplyr)
library(tidytext)
text_df <- text_df %>%
mutate_all(as.character) %>%
unnest_tokens(word, text)
这给了你:
# A tibble: 186 x 2
line word
<chr> <chr>
1 1 c
2 1 furloughs
3 1 students
4 1 do
5 1 not
6 1 have
7 1 their
8 1 books
9 1 or
10 1 needed
# ... with 176 more rows
你能用dputheadtext\u df提供一个text\u df样本吗?>dputheadtext\u df structurelistline=1:6,text=structurelisttext=cfurlough,学生没有书或所需材料,工作多而报酬少,没有,照顾免疫功能受损的配偶,做母亲、学校老师、研究人员和教授,class=data.frame,row.names=cNA,-6L,row.names=cNA,-6L,class=ctbl_-df,tbl,data.frame
library(dplyr)
library(tidytext)
text_df <- text_df %>%
mutate_all(as.character) %>%
unnest_tokens(word, text)
# A tibble: 186 x 2
line word
<chr> <chr>
1 1 c
2 1 furloughs
3 1 students
4 1 do
5 1 not
6 1 have
7 1 their
8 1 books
9 1 or
10 1 needed
# ... with 176 more rows