0

I have a data set of 30 of Cristiano Ronaldo's tweets in R. However, when I attempt to clean the data via the tm package I only get the meta data as an output instead of a cleaned version of the text. Here is my code:

##cleaning, analyse and display of data
#Libraries necessary to clean, analyse and display data
library(tm)

# Create a DataframeSource of Ronaldo_tweets
Ronaldo_source <- DataframeSource(Ronaldo_tweets)

# Convert Ronaldo_source to a corpus 
Ronaldo_corpus <- VCorpus(Ronaldo_source)

# Function to clean corpus
clean_corpus <- function(corpus){
tm_map(corpus, stripWhitespace)
tm_map(corpus, removePunctuation)
tm_map(corpus, removeNumbers)
return(corpus)
}

# Apply customized function to Ronaldo_corpus
Ronaldo_clean <- clean_corpus(Ronaldo_corpus)

#Print Ronaldo_clean
Ronaldo_clean
content(Ronaldo_clean)
  • When asking for help you should provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). We have no idea what input you are feeding in or what output you are getting since there's not enough info here to run the code ourselves. – MrFlick Aug 16 '17 at 19:08
  • I think you need to convert the JSON object from Twitter into a list and extract the tweets before you start cleaning them. – Ryan Morton Aug 16 '17 at 19:09

0 Answers0