text mining - WordCloud of transaction activities in R -


i trying generate wordcloud transaction activities in order show people spend money. transaction activities following:

description       amount albertson         20 albertson         30 albertson         35 cvs               10 cvs               40 walmart           15 walmart           44 ... 

i can generate wordcloud description's frequency. how can wordcloud sorted sum(amount) of each category? thanks!

btw here code

require(tm) require(wordcloud) require(rcolorbrewer)  data_corpus <- corpus(vectorsource(data))  data_corpus <- tm_map(data_corpus, content_transformer(tolower), mc.cores=1) data_corpus <- tm_map(data_corpus, removepunctuation, mc.cores=1) data_corpus <- tm_map(data_corpus, function(x)removewords(x,stopwords()), mc.cores=1) data_corpus <- tm_map(data_corpus, removenumbers, mc.cores=1)  pal2 <- brewer.pal(8,"dark2") png("25-34.png", width=1280,height=800) wordcloud(data_corpus, scale=c(6,.2),min.freq=50,max.words=inf, random.order=false, rot.per=.15, colors=pal2) dev.off() 

i loaded mini table dataframe called data. ran following code:

require(wordcloud) require(rcolorbrewer) library(dplyr) # group description , sum amounts data <- data %>% group_by(description) %>% summarise(amount = sum(amount))  pal2 <- brewer.pal(8,"dark2") wordcloud(data$description, freq = data$amount, scale=c(6,.2),min.freq=50,max.words=inf, random.order=false, rot.per=.15, colors=pal2) 

no need tm package. specify description in words section , amount in frequency section.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -