tag_cloud: Creating Tag Cloud in R (with Flash and JavaScript)

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/tag_cloud.R

Description

Use R to write tag data (tag words, frequency, hyperlinks and colors, etc) into JavaScript, and the JavaScript code will generate a Flash movie. Finally the tag cloud can be created with fantastic 3D rotation effect.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
tag_cloud(
  tagData,
  htmlOutput = "tagCloud.html",
  SWFPath = "tagcloud.swf",
  JSPath = "swfobject.js",
  divId = "tagCloudId",
  width = 600,
  height = 400,
  transparent = FALSE,
  tcolor = "333333",
  tcolor2 = "009900",
  hicolor = "ff0000",
  distr = "true",
  tspeed = 100,
  version = 9,
  bgcolor = "ffffff",
  useXML = FALSE,
  htmlTitle = "Tag Cloud",
  noFlashJS,
  target = NULL,
  scriptOnly = FALSE,
  encode = FALSE,
  reserved = FALSE
)

Arguments

tagData

a data.frame containing at least 3 columns: tag, link and count. Optional columns are color and hicolor

htmlOutput

filename of the HTML output

SWFPath

path of the SWF source file (‘tagcloud.swf’); see system.file("js", "tagcloud.swf", package = "fun")

JSPath

path of the JavaScript file (‘swfobject.js’); see system.file("js", "swfobject.js", package = "fun")

divId

id of the tag cloud div (HTML layer)

width, height

width and height of the tag cloud

transparent

logical; whether to use transparent backgroud for the Flash movie?

tcolor, tcolor2, hicolor, distr, tspeed

see Details

version

the required Flash version

bgcolor

backgroud color of the Flash movie

useXML

use XML file for the tag information or just a string; this will be passed to the Flash object as a variable

htmlTitle

title of the HTML file

noFlashJS

text to show if Flash or JavaScript is not supported

target

target window of the hyperlinks; possible values are NULL, '_blank', '_top', etc

scriptOnly

print the script in the console only? (if TRUE), no HTML file will be generated

encode

encode the tag XML or not? (with URLencode) set it to be TRUE when your browser does not recognize the tag XML correctly

reserved

should reserved characters be encoded? see URLencode

Details

This function is based on the WordPress plugin “wp-cumulus”. If there are any arguments you don't understand, please check the reference.

Value

NULL

Author(s)

Yihui Xie <https://yihui.org>

References

About the WordPress plugin: https://wordpress.org/plugins/wp-cumulus/

Usage of the SWFObject: http://blog.deconcept.com/swfobject/

An example of visualizing tags in my blog: https://yihui.org/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/

See Also

cat, sprintf, URLencode

Examples

1
2
3
4
5
6
7
data(tagData)
htmlFile = paste(tempfile(), ".html", sep = "")
if (file.create(htmlFile)) {
    tag_cloud(tagData, htmlFile)
    if (!interactive()) 
        browseURL(htmlFile)
}

Example output

HTML file created at  /work/tmp/tmp/Rtmp0Dl8Q6/file1d70188bb8a3.html 
sh: 0: Can't open /dev/null

fun documentation built on Oct. 24, 2020, 1:07 a.m.