1 Reply Latest reply on Sep 17, 2016 1:11 PM by Adam Crahen

    Word Cloud with R Codes Error in Tableau

    Sandeep Kotha

      Hi All,

       

      Below are the R Codes which I have used to create a Word cloud in R Studio.I have initiated RSERVE() in Rstudio and I clicked on "Manage R Connection" and the set up was successful.

      I am including line by line code and running in tableau.But it is throwing the error as shown in the below snapshot.

      Could some one help me on this?

       

      library(tm)  library(wordcloud) library(stringr) library(ggplot2)

       

      nytimesTrainstr_c(nytimesTrain$text)

      nytimesTrainCorpus = Corpus(VectorSource(c(nytimesTrain$combcol)))

      inspect(nytimesTrainCorpus[1])

      toSpace <- content_transformer(function(x, pattern) gsub(pattern, " ", x))

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, toSpace, "/|@|\\/")

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, content_transformer(tolower))

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, removeNumbers)

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, removePunctuation)

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, removeWords, stopwords("english"))

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, stripWhitespace)

      toString <- content_transformer(function(x, from, to) gsub(from, to, x))

      removeURL <- function(x) gsub("http[[:alnum:]]*", " ", x)

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, removeURL)

      nytimesTrainCorpus <- tm_map(nytimesTrainCorpus, stemDocument)

      corpusT<- tm_map(nytimesTrainCorpus, PlainTextDocument)

       

      dtm <- DocumentTermMatrix(corpusT)

      sparse_dtm = removeSparseTerms(dtm, 0.99)

      findFreqTerms(sparse_dtm, lowfreq=100)

      findAssocs(sparse_dtm, "fashion", corlimit=0.1)

      freq <- sort(colSums(as.matrix(sparse_dtm)), decreasing=TRUE) ",ATTR([Text]))

       

       

      Thank you in advance.

       

      Best Wishes,

      Sandeep