[Rcpp-devel] wordcloud

ian.fellows at stat.ucla.edu ian.fellows at stat.ucla.edu
Sat Jul 23 18:02:08 CEST 2011

Hi all,

I've just released an R package to CRAN that creates pretty looking word
clouds. I think it makes a good minimal example of how to prototype an
algorithm in R, and then bring the performance bottleneck down to c++ to
improve speed.

An example:

>crude <- tm_map(crude, removePunctuation)
>crude <- tm_map(crude, function(x)removeWords(x,stopwords()))
>tdm <- TermDocumentMatrix(crude)
>m <- as.matrix(tdm)
>v <- sort(rowSums(m),decreasing=TRUE)
>d <- data.frame(word = names(v),freq=v
+ )
Loading required package: Rcpp
>#using c++ to help layout the words
  user  system elapsed
 9.979   0.049   9.878
>#using R code to do the same layout
  user  system elapsed
151.919   0.716 146.737


More information about the Rcpp-devel mailing list