Title: | Create Word Cloud by htmlWidget |
---|---|
Description: | A fast visualization tool for creating wordcloud by using wordcloud2.js. |
Authors: | Dawei Lang |
Maintainer: | Dawei Lang <[email protected]> |
License: | GPL-2 |
Version: | 0.2.2 |
Built: | 2024-11-08 02:56:43 UTC |
Source: | https://github.com/lchiffon/wordcloud2 |
Function for Creating wordcloud theme
## S3 method for class 'wordcloud2' e1 + e2
## S3 method for class 'wordcloud2' e1 + e2
e1 |
wordcloud2 object |
e2 |
wordcloud2 themes |
wc = wordcloud2(demoFreq) wc + WCtheme(1) wc + WCtheme(2) wc + WCtheme(3) wc + WCtheme(2) + WCtheme(3)
wc = wordcloud2(demoFreq) wc + WCtheme(1) wc + WCtheme(2) wc + WCtheme(3) wc + WCtheme(2) + WCtheme(3)
A data file of words and frequency from tm package
demoFreq
demoFreq
A data set with 1011 observations of 2 variables, words and frequancy
A data file of words and frequency from tm package
demoFreqC
demoFreqC
A data set with 885 observations of 2 variables, words and frequancy
Function for Creating wordcloud with the shape of a word
letterCloud(data, word, wordSize = 0, letterFont = NULL, ...)
letterCloud(data, word, wordSize = 0, letterFont = NULL, ...)
data |
A data frame including word and freq in each column |
word |
A word to create shape for wordcloud. |
wordSize |
Parameter of the size of the word. |
letterFont |
Letter font |
... |
Other parameters for wordcloud. |
library(wordcloud2) letterCloud(demoFreq,"R")
library(wordcloud2) letterCloud(demoFreq,"R")
Function for Creating wordcloud theme
WCtheme(class = 1)
WCtheme(class = 1)
class |
class for theme in wordcloud2 |
wc = wordcloud2(demoFreq) wc + WCtheme(1) wc + WCtheme(2) wc + WCtheme(3) wc + WCtheme(2) + WCtheme(3)
wc = wordcloud2(demoFreq) wc + WCtheme(1) wc + WCtheme(2) wc + WCtheme(3) wc + WCtheme(2) + WCtheme(3)
Function for Creating wordcloud by wordcloud2.js
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)
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)
data |
A data frame including word and freq in each column |
size |
Font size, default is 1. The larger size means the bigger word. |
minSize |
minimum font size to draw on the canvas. |
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. |
fontFamily |
Font to use. |
fontWeight |
Font weight to use, e.g. normal, bold or 600 |
color |
color of the text, keyword 'random-dark' and 'random-light' can be used. color vector is also supported in this param |
backgroundColor |
Color of the background. |
minRotation |
If the word should rotate, the minimum rotation (in rad) the text should rotate. |
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. |
shuffle |
Shuffle the points to draw so the result will be different each time for the same list and settings. |
rotateRatio |
Probability for the word to rotate. Set the number to 1 to always rotate. |
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'. |
ellipticity |
degree of "flatness" of the shape wordcloud2.js should draw. |
widgetsize |
size of the widgets |
figPath |
The path to a figure used as a mask. |
hoverFunction |
Callback to call when the cursor enters or leaves a region occupied by a word. A string of java script function. |
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'))
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'))
Function for plotting wordcloud2 in shiny
wordcloud2Output(outputId, width = "100%", height = "400px") clickedWordInputId is automatically generated by: paste0(outputId, "_clicked_word")) renderWordcloud2(expr, env = parent.frame(), quoted = FALSE) wordcloud2Output(outputId, width = "100%", height = "400px") renderWordcloud2(expr, env = parent.frame(), quoted = FALSE)
wordcloud2Output(outputId, width = "100%", height = "400px") clickedWordInputId is automatically generated by: paste0(outputId, "_clicked_word")) renderWordcloud2(expr, env = parent.frame(), quoted = FALSE) wordcloud2Output(outputId, width = "100%", height = "400px") renderWordcloud2(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a networkD3 graph |
env |
The environment in which to evaluate |
quoted |
Is |
Use renderWordcloud2 to render an wordcloud2 object and use wordcloud2Output output an wordcloud2 object. See more details in shiny package.
This will be the same value as shown in the hover information (example: super:32
).