Library "tm" Error Corpus.Default()

Hi guys,

Please, Im trying to build a corpus and a wordcloud. My data comes from a csv with 36000 answers (qualitative). Could you please help me to understand the following error:

install.packages("tm")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into �C:/Users/felipe.vaz/Documents/R/win-library/3.6�
(as �lib� is unspecified)
tentando a URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/tm_0.7-7.zip'
Content type 'application/zip' length 1370539 bytes (1.3 MB)
downloaded 1.3 MB

package ‘tm’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\felipe.vaz\AppData\Local\Temp\RtmpcnchN0\downloaded_packages

library("tm")
Carregando pacotes exigidos: NLP

Attaching package: �tm�

The following objects are masked from �package:quanteda�:

as.DocumentTermMatrix, stopwords

Data <- read.csv2("Dados_2.csv", stringsAsFactors = FALSE)
Data_bag <- paste(Data$Resposta.Quali, collapse = " ")
Data_source <- VectorSource(Data_bag)
Corpus <- corpus(Data_source)
Error in corpus.default(Data_source) :
corpus() only works on character, corpus, Corpus, data.frame, kwic objects.

Try

mycorpus <- VCorpus(x = VectorSource( Data_bag) ),
                     readerControl = list(reader=readPlain,
                                          language="en"))

Thank you, does not work...

"Error: ',' unexpected in "mycorpus <- VCorpus (x = VectorSource (Data_bag)),""

Ok. I had a typo, as I'm on mobile the 2nd bracket close after databag should be delete. Because the brackets need to pair up, right?
Sorry about the confusion.

WOW, works niceeeee dudeee....thx

but, to understand, could you please tell me what it does?

Turned your vector of character/text into a Volatile Corpus.
It's a bit dry but the documentation is here:
https://www.google.com/url?sa=t&source=web&rct=j&url=https://cran.r-project.org/web/packages/tm/vignettes/tm.pdf&ved=2ahUKEwj7gbCS4_XnAhWysHEKHeM8AhwQFjABegQIBhAC&usg=AOvVaw19zpJSg_-Tt2mTaxYPbb6P
https://cran.r-project.org › tm
Introduction to the tm Package Text Mining in R - CRAN - R Project

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.