diff --git a/DESCRIPTION b/DESCRIPTION index 4993e3c..64eb061 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,24 +1,24 @@ -Package: wordcloud2 -Type: Package -Title: Create Word Cloud by htmlWidget -Version: 0.2.0 -Author: Dawei Lang -Description: A fast visualization tool for creating wordcloud - by using wordcloud2.js. -License: GPL-2 -Depends: - R (>= 3.1.0) -LazyData: TRUE -VignetteBuilder: knitr -Imports: - htmlwidgets, - base64enc, - grDevices, - graphics -Suggests: - knitr -Enhances: shiny (>= 0.12) -URL: https://github.com/lchiffon/wordcloud2 -BugReports: https://github.com/lchiffon/wordcloud2/issues -Maintainer: Dawei Lang -RoxygenNote: 5.0.1 +Package: wordcloud2 +Type: Package +Title: Create Word Cloud by htmlWidget +Version: 0.2.0 +Author: Dawei Lang +Description: A fast visualization tool for creating wordcloud + by using wordcloud2.js. +License: GPL-2 +Depends: + R (>= 3.1.0) +LazyData: TRUE +VignetteBuilder: knitr +Imports: + htmlwidgets, + base64enc, + grDevices, + graphics +Suggests: + knitr +Enhances: shiny (>= 0.12) +URL: https://github.com/lchiffon/wordcloud2 +BugReports: https://github.com/lchiffon/wordcloud2/issues +Maintainer: Dawei Lang +RoxygenNote: 6.0.1 diff --git a/NAMESPACE b/NAMESPACE index 27e0029..8cf7354 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,11 +1,15 @@ -# Generated by roxygen2 (4.1.1): do not edit by hand - -S3method("+",wordcloud2) -export(WCtheme) -export(letterCloud) -export(renderWordcloud2) -export(wordcloud2) -export(wordcloud2Output) -import(htmlwidgets) -importFrom("grDevices", "dev.off", "png") -importFrom("graphics", "par", "plot.new", "strwidth", "text") +# Generated by roxygen2: do not edit by hand + +S3method("+",wordcloud2) +export(WCtheme) +export(letterCloud) +export(renderWordcloud2) +export(wordcloud2) +export(wordcloud2Output) +import(htmlwidgets) +importFrom(grDevices,dev.off) +importFrom(grDevices,png) +importFrom(graphics,par) +importFrom(graphics,plot.new) +importFrom(graphics,strwidth) +importFrom(graphics,text) diff --git a/R/letterCloud.R b/R/letterCloud.R index 7d5a139..ee6bb1e 100644 --- a/R/letterCloud.R +++ b/R/letterCloud.R @@ -1,49 +1,51 @@ -##' Create wordcloud with the shape of a word -##' -##' @description -##' Function for Creating wordcloud with the shape of a word -##' -##' @usage -##' letterCloud(data, word, wordSize = 0, letterFont = NULL, ...) -##' -##' @param data A data frame including word and freq in each column -##' @param word A word to create shape for wordcloud. -##' @param wordSize Parameter of the size of the word. -##' @param letterFont Letter font -##' @param ... Other parameters for wordcloud. -##' -##' @examples -##' library(wordcloud2) -##' -##' letterCloud(demoFreq,"R") -#' @export - - -letterCloud = function(data, word, wordSize = 0, - letterFont = NULL,...){ - fileid = paste('ID', format(Sys.time(), "%Y%m%d%H%M%S"), - round(proc.time()[3]*100), sep="_") - figDir = paste0(tempdir(),"/",fileid,".png") - - # word = "COS" - if(nchar(word)==1){ - ofCex = -25 - }else if(nchar(word)==2){ - ofCex = -10 - }else{ - ofCex = -1 - } - png(filename = figDir,width = 800,height = 600) - offset = par(mar = par()$mar) - op = par(mar = c(0,0,0,0)) - plot.new() - - text(0.5, 0.5, word, font = 2, family = letterFont, - cex = 1/strwidth(word) + ofCex + wordSize) - - dev.off() - par(offset) - - wordcloud2(data,figPath = figDir,...) - -} +##' Create wordcloud with the shape of a word +##' +##' @description +##' Function for Creating wordcloud with the shape of a word +##' +##' @usage +##' letterCloud(data, word, wordSize = 0, letterFont = NULL, ...) +##' +##' @param data A data frame including word and freq in each column +##' @param word A word to create shape for wordcloud. +##' @param wordSize Parameter of the size of the word. +##' @param letterFont Letter font +##' @param ... Other parameters for wordcloud. +##' +##' @examples +##' library(wordcloud2) +##' +##' letterCloud(demoFreq,"R") +#' @importFrom grDevices dev.off png +#' @importFrom graphics par plot.new strwidth text +#' @export + + +letterCloud = function(data, word, wordSize = 0, + letterFont = NULL,...){ + fileid = paste('ID', format(Sys.time(), "%Y%m%d%H%M%S"), + round(proc.time()[3]*100), sep="_") + figDir = paste0(tempdir(),"/",fileid,".png") + + # word = "COS" + if(nchar(word)==1){ + ofCex = -25 + }else if(nchar(word)==2){ + ofCex = -10 + }else{ + ofCex = -1 + } + png(filename = figDir,width = 800,height = 600) + offset = par(mar = par()$mar) + op = par(mar = c(0,0,0,0)) + plot.new() + + text(0.5, 0.5, word, font = 2, family = letterFont, + cex = 1/strwidth(word) + ofCex + wordSize) + + dev.off() + par(offset) + + wordcloud2(data,figPath = figDir,...) + +} diff --git a/R/wordcloud2.R b/R/wordcloud2.R index 90625ef..4192ea3 100644 --- a/R/wordcloud2.R +++ b/R/wordcloud2.R @@ -9,7 +9,7 @@ ##' color = 'random-dark', backgroundColor = "white", ##' minRotation = -pi/4, maxRotation = pi/4, shuffle = TRUE, ##' rotateRatio = 0.4, shape = 'circle', ellipticity = 0.65, -##' widgetsize = NULL, figPath = NULL, hoverFunction = NULL) +##' widgetsize = NULL, figPath = NULL, hoverFunction = NULL, seed = NULL) ##' ##' @param data A data frame including word and freq in each column ##' @param size Font size, default is 1. The larger size means the bigger word. @@ -35,6 +35,7 @@ ##' @param widgetsize size of the widgets ##' @param hoverFunction Callback to call when the cursor enters or leaves a region occupied ##' by a word. A string of java script function. +##' @param seed Seed to pass to the JS library. Useful if you want a reproducible figure. ##' ##' @examples ##'library(wordcloud2) @@ -92,7 +93,8 @@ wordcloud2 <- function(data, ellipticity = 0.65, widgetsize = NULL, figPath = NULL, - hoverFunction = NULL + hoverFunction = NULL, + seed = NULL ) { if("table" %in% class(data)){ dataOut = data.frame(name = names(data), @@ -145,10 +147,10 @@ wordcloud2 <- function(data, shape = shape, ellipticity = ellipticity, figBase64 = base64, - hover = htmlwidgets::JS(hoverFunction) + hover = htmlwidgets::JS(hoverFunction), + seed = seed ) - chart = htmlwidgets::createWidget("wordcloud2", settings, width = widgetsize[1], height = widgetsize[2], @@ -161,10 +163,12 @@ wordcloud2 <- function(data, htmlwidgets::onRender(chart,"function(el,x){ + var iii; + iii = true; console.log(123); if(!iii){ window.location.reload(); - iii = False; + iii = false; } }") diff --git a/inst/htmlwidgets/lib/wordcloud2-0.0.1/wordcloud2-all.js b/inst/htmlwidgets/lib/wordcloud2-0.0.1/wordcloud2-all.js index 03a48b5..30e392c 100644 --- a/inst/htmlwidgets/lib/wordcloud2-0.0.1/wordcloud2-all.js +++ b/inst/htmlwidgets/lib/wordcloud2-0.0.1/wordcloud2-all.js @@ -208,7 +208,9 @@ if (!window.clearImmediate) { classes: null, hover: null, - click: null + click: null, + + seed: null }; if (options) { @@ -219,6 +221,19 @@ if (!window.clearImmediate) { } } + /* Define a random function using a seed */ + var random; + if (settings.seed === null) { + random = function random() { + return Math.random(); + }; + } else { + random = function random() { + var x = Math.sin(settings.seed++) * 10000; + return x - Math.floor(x); + }; + } + /* Convert weightFactor into a function */ if (typeof settings.weightFactor !== 'function') { var factor = settings.weightFactor; @@ -333,9 +348,9 @@ if (!window.clearImmediate) { var getTextColor; function random_hsl_color(min, max) { return 'hsl(' + - (Math.random() * 360).toFixed() + ',' + - (Math.random() * 30 + 70).toFixed() + '%,' + - (Math.random() * (max - min) + min).toFixed() + '%)'; + (random() * 360).toFixed() + ',' + + (random() * 30 + 70).toFixed() + '%,' + + (random() * (max - min) + min).toFixed() + '%)'; } switch (settings.color) { case 'random-dark': @@ -468,7 +483,7 @@ if (!window.clearImmediate) { return 0; } - if (Math.random() > settings.rotateRatio) { + if (random() > settings.rotateRatio) { return 0; } @@ -476,7 +491,7 @@ if (!window.clearImmediate) { return minRotation; } - return minRotation + Math.random() * rotationRange; + return minRotation + random() * rotationRange; }; var getTextInfo = function getTextInfo(word, weight, rotateDeg) { diff --git a/inst/htmlwidgets/wordcloud2.js b/inst/htmlwidgets/wordcloud2.js index b6e0067..a26d42a 100644 --- a/inst/htmlwidgets/wordcloud2.js +++ b/inst/htmlwidgets/wordcloud2.js @@ -43,7 +43,8 @@ HTMLWidgets.widget({ drawMask: x.drawMask, maskColor: x.maskColor, maskGapWidth: x.maskGapWidth, - hover: x.hover || cv_handleHover + hover: x.hover || cv_handleHover, + seed: x.seed }); } }, diff --git a/man/WCtheme.Rd b/man/WCtheme.Rd index 3babae6..63210ae 100644 --- a/man/WCtheme.Rd +++ b/man/WCtheme.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/theme.R \name{WCtheme} \alias{WCtheme} @@ -20,4 +20,3 @@ wc + WCtheme(2) wc + WCtheme(3) wc + WCtheme(2) + WCtheme(3) } - diff --git a/man/demoFreq.Rd b/man/demoFreq.Rd index c2a98a3..00105ca 100644 --- a/man/demoFreq.Rd +++ b/man/demoFreq.Rd @@ -1,15 +1,14 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/data-definitions.R -\docType{data} -\name{demoFreq} -\alias{demoFreq} -\title{Demo dataset with Words and Frequency} -\format{A data set with 1011 observations of 2 variables, words and frequancy} -\usage{ -demoFreq -} -\description{ -A data file of words and frequency from tm package -} -\keyword{datasets} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data-definitions.R +\docType{data} +\name{demoFreq} +\alias{demoFreq} +\title{Demo dataset with Words and Frequency} +\format{A data set with 1011 observations of 2 variables, words and frequancy} +\usage{ +demoFreq +} +\description{ +A data file of words and frequency from tm package +} +\keyword{datasets} diff --git a/man/demoFreqC.Rd b/man/demoFreqC.Rd index 536448e..9dc5b80 100644 --- a/man/demoFreqC.Rd +++ b/man/demoFreqC.Rd @@ -1,15 +1,14 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/data-definitions.R -\docType{data} -\name{demoFreqC} -\alias{demoFreqC} -\title{Demo dataset with Chinese character Words and Frequency} -\format{A data set with 885 observations of 2 variables, words and frequancy} -\usage{ -demoFreqC -} -\description{ -A data file of words and frequency from tm package -} -\keyword{datasets} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data-definitions.R +\docType{data} +\name{demoFreqC} +\alias{demoFreqC} +\title{Demo dataset with Chinese character Words and Frequency} +\format{A data set with 885 observations of 2 variables, words and frequancy} +\usage{ +demoFreqC +} +\description{ +A data file of words and frequency from tm package +} +\keyword{datasets} diff --git a/man/letterCloud.Rd b/man/letterCloud.Rd index 5e6c1c8..5a4493c 100644 --- a/man/letterCloud.Rd +++ b/man/letterCloud.Rd @@ -1,28 +1,27 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/letterCloud.R -\name{letterCloud} -\alias{letterCloud} -\title{Create wordcloud with the shape of a word} -\usage{ -letterCloud(data, word, wordSize = 0, letterFont = NULL, ...) -} -\arguments{ -\item{data}{A data frame including word and freq in each column} - -\item{word}{A word to create shape for wordcloud.} - -\item{wordSize}{Parameter of the size of the word.} - -\item{letterFont}{Letter font} - -\item{...}{Other parameters for wordcloud.} -} -\description{ -Function for Creating wordcloud with the shape of a word -} -\examples{ -library(wordcloud2) - -letterCloud(demoFreq,"R") -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/letterCloud.R +\name{letterCloud} +\alias{letterCloud} +\title{Create wordcloud with the shape of a word} +\usage{ +letterCloud(data, word, wordSize = 0, letterFont = NULL, ...) +} +\arguments{ +\item{data}{A data frame including word and freq in each column} + +\item{word}{A word to create shape for wordcloud.} + +\item{wordSize}{Parameter of the size of the word.} + +\item{letterFont}{Letter font} + +\item{...}{Other parameters for wordcloud.} +} +\description{ +Function for Creating wordcloud with the shape of a word +} +\examples{ +library(wordcloud2) + +letterCloud(demoFreq,"R") +} diff --git a/man/plus-.wordcloud2.Rd b/man/plus-.wordcloud2.Rd index 7b74a48..4d74436 100644 --- a/man/plus-.wordcloud2.Rd +++ b/man/plus-.wordcloud2.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot-construction.R \name{+.wordcloud2} \alias{+.wordcloud2} @@ -22,4 +22,3 @@ wc + WCtheme(2) wc + WCtheme(3) wc + WCtheme(2) + WCtheme(3) } - diff --git a/man/wordcloud2-shiny.Rd b/man/wordcloud2-shiny.Rd index e4d7777..d366b90 100644 --- a/man/wordcloud2-shiny.Rd +++ b/man/wordcloud2-shiny.Rd @@ -1,37 +1,36 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/renderWordcloud2.R -\name{wordcloud2-shiny} -\alias{renderWordcloud2} -\alias{wordcloud2-shiny} -\alias{wordcloud2Output} -\title{Plot wordcloud2 in shiny} -\usage{ -wordcloud2Output(outputId, width = "100\%", height = "400px") -renderWordcloud2(expr, env = parent.frame(), quoted = FALSE) - -wordcloud2Output(outputId, width = "100\%", height = "400px") - -renderWordcloud2(expr, env = parent.frame(), quoted = FALSE) -} -\arguments{ -\item{outputId}{output variable to read from} - -\item{width,height}{Must be a valid CSS unit (like \code{"100\%"}, -\code{"400px"}, \code{"auto"}) or a number, which will be coerced to a -string and have \code{"px"} appended.} - -\item{expr}{An expression that generates a networkD3 graph} - -\item{env}{The environment in which to evaluate \code{expr}.} - -\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This - is useful if you want to save an expression in a variable.} -} -\description{ -Function for plotting wordcloud2 in shiny -} -\details{ -Use renderWordcloud2 to render an wordcloud2 object and use wordcloud2Output -output an wordcloud2 object. See more details in shiny package. -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/renderWordcloud2.R +\name{wordcloud2-shiny} +\alias{wordcloud2-shiny} +\alias{wordcloud2Output} +\alias{renderWordcloud2} +\title{Plot wordcloud2 in shiny} +\usage{ +wordcloud2Output(outputId, width = "100\%", height = "400px") +renderWordcloud2(expr, env = parent.frame(), quoted = FALSE) + +wordcloud2Output(outputId, width = "100\%", height = "400px") + +renderWordcloud2(expr, env = parent.frame(), quoted = FALSE) +} +\arguments{ +\item{outputId}{output variable to read from} + +\item{width, height}{Must be a valid CSS unit (like \code{"100\%"}, +\code{"400px"}, \code{"auto"}) or a number, which will be coerced to a +string and have \code{"px"} appended.} + +\item{expr}{An expression that generates a networkD3 graph} + +\item{env}{The environment in which to evaluate \code{expr}.} + +\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This +is useful if you want to save an expression in a variable.} +} +\description{ +Function for plotting wordcloud2 in shiny +} +\details{ +Use renderWordcloud2 to render an wordcloud2 object and use wordcloud2Output +output an wordcloud2 object. See more details in shiny package. +} diff --git a/man/wordcloud2.Rd b/man/wordcloud2.Rd index 57797c3..0eb8fd3 100644 --- a/man/wordcloud2.Rd +++ b/man/wordcloud2.Rd @@ -1,93 +1,94 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/wordcloud2.R -\name{wordcloud2} -\alias{wordcloud2} -\title{Create wordcloud by wordcloud2.js} -\usage{ -wordcloud2(data, size = 1, minSize = 0, gridSize = 0, - fontFamily = 'Segoe UI', fontWeight = 'bold', - color = 'random-dark', backgroundColor = "white", - minRotation = -pi/4, maxRotation = pi/4, shuffle = TRUE, - rotateRatio = 0.4, shape = 'circle', ellipticity = 0.65, - widgetsize = NULL, figPath = NULL, hoverFunction = NULL) -} -\arguments{ -\item{data}{A data frame including word and freq in each column} - -\item{size}{Font size, default is 1. The larger size means the bigger word.} - -\item{minSize}{A character string of the subtitle} - -\item{gridSize}{Size of the grid in pixels for marking the availability of the canvas -the larger the grid size, the bigger the gap between words.} - -\item{fontFamily}{Font to use.} - -\item{fontWeight}{Font weight to use, e.g. normal, bold or 600} - -\item{color}{color of the text, keyword 'random-dark' and 'random-light' can be used. -color vector is also supported in this param} - -\item{backgroundColor}{Color of the background.} - -\item{minRotation}{If the word should rotate, the minimum rotation -(in rad) the text should rotate.} - -\item{maxRotation}{If the word should rotate, the maximum rotation (in rad) the text should rotate. -Set the two value equal to keep all text in one angle.} - -\item{shuffle}{Shuffle the points to draw so the result will be different each time for the same list and settings.} - -\item{rotateRatio}{Probability for the word to rotate. Set the number to 1 to always rotate.} - -\item{shape}{The shape of the "cloud" to draw. Can be a keyword present. Available presents are 'circle' -(default), 'cardioid' (apple or heart shape curve, the most known polar equation), -'diamond' (alias of square), 'triangle-forward', 'triangle', 'pentagon', and 'star'.} - -\item{ellipticity}{degree of "flatness" of the shape wordcloud2.js should draw.} - -\item{widgetsize}{size of the widgets} - -\item{figPath}{The path to a figure used as a mask.} - -\item{hoverFunction}{Callback to call when the cursor enters or leaves a region occupied -by a word. A string of java script function.} -} -\description{ -Function for Creating wordcloud by wordcloud2.js -} -\examples{ -library(wordcloud2) -# Global variables can go here - - - -wordcloud2(demoFreq) -wordcloud2(demoFreq, size = 2) - -wordcloud2(demoFreq, size = 1,shape = 'pentagon') -wordcloud2(demoFreq, size = 1,shape = 'star') - -wordcloud2(demoFreq, size = 2, - color = "random-light", backgroundColor = "grey") - -wordcloud2(demoFreq, size = 2, minRotation = -pi/2, maxRotation = -pi/2) -wordcloud2(demoFreq, size = 2, minRotation = -pi/6, maxRotation = -pi/6, - rotateRatio = 1) -wordcloud2(demoFreq, size = 2, minRotation = -pi/6, maxRotation = pi/6, - rotateRatio = 0.9) - -wordcloud2(demoFreqC, size = 2, - color = "random-light", backgroundColor = "grey") -wordcloud2(demoFreqC, size = 2, minRotation = -pi/6, maxRotation = -pi/6, - rotateRatio = 1) - -# Color Vector - -colorVec = rep(c('red', 'skyblue'), length.out=nrow(demoFreq)) -wordcloud2(demoFreq, color = colorVec, fontWeight = "bold") - -wordcloud2(demoFreq, - color = ifelse(demoFreq[, 2] > 20, 'red', 'skyblue')) -} - +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/wordcloud2.R +\name{wordcloud2} +\alias{wordcloud2} +\title{Create wordcloud by wordcloud2.js} +\usage{ +wordcloud2(data, size = 1, minSize = 0, gridSize = 0, + fontFamily = 'Segoe UI', fontWeight = 'bold', + color = 'random-dark', backgroundColor = "white", + minRotation = -pi/4, maxRotation = pi/4, shuffle = TRUE, + rotateRatio = 0.4, shape = 'circle', ellipticity = 0.65, + widgetsize = NULL, figPath = NULL, hoverFunction = NULL, seed = NULL) +} +\arguments{ +\item{data}{A data frame including word and freq in each column} + +\item{size}{Font size, default is 1. The larger size means the bigger word.} + +\item{minSize}{minimum font size to draw on the canvas.} + +\item{gridSize}{Size of the grid in pixels for marking the availability of the canvas +the larger the grid size, the bigger the gap between words.} + +\item{fontFamily}{Font to use.} + +\item{fontWeight}{Font weight to use, e.g. normal, bold or 600} + +\item{color}{color of the text, keyword 'random-dark' and 'random-light' can be used. +color vector is also supported in this param} + +\item{backgroundColor}{Color of the background.} + +\item{minRotation}{If the word should rotate, the minimum rotation +(in rad) the text should rotate.} + +\item{maxRotation}{If the word should rotate, the maximum rotation (in rad) the text should rotate. +Set the two value equal to keep all text in one angle.} + +\item{shuffle}{Shuffle the points to draw so the result will be different each time for the same list and settings.} + +\item{rotateRatio}{Probability for the word to rotate. Set the number to 1 to always rotate.} + +\item{shape}{The shape of the "cloud" to draw. Can be a keyword present. Available presents are 'circle' +(default), 'cardioid' (apple or heart shape curve, the most known polar equation), +'diamond' (alias of square), 'triangle-forward', 'triangle', 'pentagon', and 'star'.} + +\item{ellipticity}{degree of "flatness" of the shape wordcloud2.js should draw.} + +\item{widgetsize}{size of the widgets} + +\item{figPath}{The path to a figure used as a mask.} + +\item{hoverFunction}{Callback to call when the cursor enters or leaves a region occupied +by a word. A string of java script function.} + +\item{seed}{Seed to pass to the JS library. Useful if you want a reproducible figure.} +} +\description{ +Function for Creating wordcloud by wordcloud2.js +} +\examples{ +library(wordcloud2) +# Global variables can go here + + + +wordcloud2(demoFreq) +wordcloud2(demoFreq, size = 2) + +wordcloud2(demoFreq, size = 1,shape = 'pentagon') +wordcloud2(demoFreq, size = 1,shape = 'star') + +wordcloud2(demoFreq, size = 2, + color = "random-light", backgroundColor = "grey") + +wordcloud2(demoFreq, size = 2, minRotation = -pi/2, maxRotation = -pi/2) +wordcloud2(demoFreq, size = 2, minRotation = -pi/6, maxRotation = -pi/6, + rotateRatio = 1) +wordcloud2(demoFreq, size = 2, minRotation = -pi/6, maxRotation = pi/6, + rotateRatio = 0.9) + +wordcloud2(demoFreqC, size = 2, + color = "random-light", backgroundColor = "grey") +wordcloud2(demoFreqC, size = 2, minRotation = -pi/6, maxRotation = -pi/6, + rotateRatio = 1) + +# Color Vector + +colorVec = rep(c('red', 'skyblue'), length.out=nrow(demoFreq)) +wordcloud2(demoFreq, color = colorVec, fontWeight = "bold") + +wordcloud2(demoFreq, + color = ifelse(demoFreq[, 2] > 20, 'red', 'skyblue')) +} diff --git a/wordcloud2.Rproj b/wordcloud2.Rproj index 497f8bf..270314b 100644 --- a/wordcloud2.Rproj +++ b/wordcloud2.Rproj @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace