#' Produces wordcloud from the output function
#'
#' @param df A dataframe generated by the scrapescholar function.
#' @return Wordcloud for \code{df}.
#' @examples
#' wordcloudlame(output)
wordcloudlame <- function(df){
library(wordcloud)
library(tm)
library(SnowballC)
excerpt = df$excerpt
#save it as a corpus file - only the abstract excluding the keywords
abstract_article <- VCorpus(VectorSource(excerpt))
#transformations - in tm package this is done using the tm_map function
#removing whitespace
abstract_article %>% tm_map(stripWhitespace) -> abstract_article
#removing stopwords
abstract_article %>% tm_map(removeWords, stopwords("english")) -> abstract_article
#stemming
abstract_article %>% tm_map(stemDocument) -> abstract_article
#Term-Document Matrices
dtm <- DocumentTermMatrix(abstract_article) %>% removeSparseTerms(0.8)
#convert into a matrix
dtm <- as.matrix(dtm)
dtm <- as.data.frame(dtm)
#create vector for data passed to the wordcloud function
wordclouddata <- apply(dtm, 2, sum)
#create word
wordcloud(names(wordclouddata), wordclouddata)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.