Created
March 26, 2018 12:59
-
-
Save bwv988/f60fac1204b52de2e67c97b32266392f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate word clouds from R. | |
# RS10062015 | |
# May need to install the below packages. | |
#req <- c("wordcloud", "tm") | |
#install.packages(req) | |
library(tm) | |
library(wordcloud) | |
# Set output dir. | |
#setwd("~/Temp") | |
# Create buzzword data and scale relative to competency. | |
buzzwords <- c("datascience", "agile", "c", "c++", "linux", | |
"hadoop", "cloud", "gnu", "git", "java", | |
"ML", "usability", "python", "DevOps", "architecture", | |
"concurrency", "javascript", "web", "docker", "lxc") | |
# Absolute weights applied to the buzzwords. | |
weights <- c(10, 6, 4, 5, 8, | |
3, 4, 6, 3, 7, | |
5, 6, 4, 3, 3, | |
3, 5, 5, 3, 7) | |
# Calculate relative weights. | |
scale <- 100 | |
rel.weights <- weights / sum(weights) | |
buzz <- rep(buzzwords, rel.weights * scale) | |
# Turn into Corpus object. | |
data <- Corpus(DataframeSource(data.frame(doc_id="mydoc", | |
text = buzz))) | |
pdf("cloud.pdf") | |
wordcloud(buzz, | |
random.order=FALSE, | |
rot.per=0.35, min.freq=1, use.r.layout=FALSE, | |
colors=brewer.pal(8, "Dark2")) | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment