<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Statistics, R, Graphics and Fun &#187; R4X</title>
	<atom:link href="http://yihui.name/en/tag/r4x/feed/" rel="self" type="application/rss+xml" />
	<link>http://yihui.name/en</link>
	<description>Yihui XIE</description>
	<lastBuildDate>Thu, 26 Aug 2010 03:32:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Creating Tag Cloud Using R and Flash / JavaScript (SWFObject)</title>
		<link>http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/</link>
		<comments>http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 08:07:32 +0000</pubDate>
		<dc:creator>Yihui Xie</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[R Programming]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Gorjanc Gregor]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[maptools]]></category>
		<category><![CDATA[pointLabel()]]></category>
		<category><![CDATA[R Language]]></category>
		<category><![CDATA[R4X]]></category>
		<category><![CDATA[Romain Francois]]></category>
		<category><![CDATA[Simon Urbanek]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[SWFObject]]></category>
		<category><![CDATA[Tag Cloud]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp-cumulus]]></category>

		<guid isPermaLink="false">http://yihui.name/en/?p=224</guid>
		<description><![CDATA[ag cloud is a bunch of words drawn in a graph with their sizes proportional to their frequency; it&#8217;s widely used in blogs to visualize tags. We can observe important words quickly from a tag cloud, as they often appear in large fontsize. Tony N. Brown asked how to &#8220;graphically represent frequency of words in [...]]]></description>
			<content:encoded><![CDATA[<a href="http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/"><span class="dropcap-red">T</span></a>ag cloud is a bunch of words drawn in a graph with their sizes proportional to their frequency; it&#8217;s widely used in blogs to visualize tags. We can observe important words quickly from a tag cloud, as they often appear in large fontsize. Tony N. Brown asked how to &#8220;<a title="graphically represent frequency of words in a speech" href="https://stat.ethz.ch/pipermail/r-help/2009-June/200645.html" target="_blank">graphically represent frequency of words in a speech</a>&#8221; the other day in R-help list, which is actually a problem about the tag cloud:</p>
<blockquote><p>I recently saw a graph on television that displayed selected words/phrases in a speech scaled in size according to their frequency. So words/phrases that were often used appeared large and words that were rarely used appeared small. [...]</blockquote>
<p>Marc Schwartz mentioned that <a title="Gorjanc Gregor" href="http://ggorjan.blogspot.com/" target="_blank">Gorjanc Gregor</a> has done <a title="tagCloud using grid graphics by Gorjanc Gregor" href="http://www.bfro.uni-lj.si/MR/ggorjan/software/R/index.html#tagCloud" target="_blank">some work</a> years ago using R (in grid graphics). The obstacle of creating tag cloud in R, as Gorjanc wrote, lies in deciding the placement of words, and it would be much easier for other applications such as browsers to arrange the texts. That&#8217;s true &#8212; there have already been a lot of mature programs to deal with tag cloud. One of them is the <code>wp-cumulus</code> plugin for WordPress, which makes use of a Flash object to generate the tag cloud, and it has fantastic 3D rotation effect of the cloud.</p>
<h1>1. Arranging text labels with <code>pointLabel()</code></h1>
<p>Before introducing how to port the plugin into R, I&#8217;d like to introduce an R function <code>pointLabel()</code> in <code>maptools</code> package and it can partially solve the problem of arranging text labels in a plot (using simulated annealing or genetic algorithm). Here is a simulated example:</p>
<div id="attachment_226" class="wp-caption aligncenter" style="width: 560px"><a rel="attachment wp-att-226" href="http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/tagcloud-with-pointlabel/"><img class="size-full wp-image-226" style="border: 1px solid black;" title="Simulated Tag Cloud with R function pointLabel() in maptools" src="http://yihui.name/en/wp-content/uploads/2009/06/tagcloud-with-pointlabel.png" alt="Simulated Tag Cloud with R function pointLabel() in maptools" width="550" height="400" /></a><p class="wp-caption-text">Simulated Tag Cloud with R function pointLabel() in maptools</p></div>
<p><span id="more-224"></span></p>
<pre>library(maptools)
set.seed(123)
x = runif(19)
y = runif(19)
w = c("R", "is", "free", "software", "and", "comes",
    "with", "ABSOLUTELY", "NO", "WARRANTY", "You", "are", "welcome",
    "to", "redistribute", "it", "under", "certain", "conditions")
par(ann = FALSE, xpd = NA, mar = rep(2, 4))
plot(x, y, type = "n", axes = FALSE)
pointLabel(x, y, w, cex = runif(19, 1, 5))</pre>
<p>I was fortunate to get a very neat graph with no labels overlapping, but I don&#8217;t think this is a good solution, as it doesn&#8217;t take care of the initial locations of the words. My rough idea about deciding the initial locations is to sample on circles with radii proportional to the frequency, i.e. let <img src="http://www.forkosh.dreamhost.com/mimetex.cgi?%5Creverse%20x%3D%5Ctextrm%7Bfreq%7D%2A%5Csin%28%5Ctheta%29" title="x=\textrm{freq}*\sin(\theta)" alt="x=\textrm{freq}*\sin(\theta)" align="absmiddle" /> and <img src="http://www.forkosh.dreamhost.com/mimetex.cgi?%5Creverse%20y%3D%5Ctextrm%7Bfreq%7D%2A%5Ccos%28%5Ctheta%29" title="y=\textrm{freq}*\cos(\theta)" alt="y=\textrm{freq}*\cos(\theta)" align="absmiddle" /> where <img src="http://www.forkosh.dreamhost.com/mimetex.cgi?%5Creverse%20%5Ctheta%5Csim%20U%280%2C2%5Cpi%29" title="\theta\sim U(0,2\pi)" alt="\theta\sim U(0,2\pi)" align="absmiddle" />. In this case, important words will be placed near the center of the plot.</p>
<h1>2. Creating tag cloud in a Flash movie using R</h1>
<p>The problem becomes quite easy with a Flash movie <a href="http://www.roytanck.com/2008/05/19/how-to-repurpose-my-tag-cloud-flash-movie/" target="_blank"><code>tagcloud.swf</code></a> and a JavaScript program <a href="http://blog.deconcept.com/swfobject/" target="_blank"><code>swfobject.js</code></a>. The mechanism, briefly speaking, is that the tag information is passed to the Flash object by JavaScript, and the Flash object will read the variable <code>tagcloud</code> where the sizes, colors and hyperlinks of tags are stored. Finally the tags are visualized like rotating cloud.</p>
<p>It&#8217;s not difficult to pass the tag information to JavaScript in pure text. Below is the function which will create an HTML page by default with a tag cloud Flash movie inside it:</p>
<span class="download">Download the source code: <a href="http://yihui.name/en/wp-content/uploads/2009/06/tagcloudr.gz">tagCloud.r.gz</a> (1.18Kb)</span>
<pre>#------------------------------------------------------------------------------#
# generating tag cloud in R using Flash and SWFObject                          #
# tagData: a data.frame containing columns 'tag', 'link', 'count' and optional #
#     columns 'color' and 'hicolor'                                            #
# other parameters are self-explaining if you are familiar with                #
#     the WP plugin 'wp-cumulus'                                               #
#------------------------------------------------------------------------------#
tagCloud = function(tagData, htmlOutput = "tagCloud.html",
    SWFPath, JSPath, 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) {
    if (missing(SWFPath))
        SWFPath = "http://www.roytanck.com/wp-content/plugins/wp-cumulus/tagcloud.swf"
    if (missing(JSPath))
        JSPath = "http://www.roytanck.com/wp-content/plugins/wp-cumulus/swfobject.js"
    if (missing(noFlashJS))
        noFlashJS = "This will be shown to users with no Flash or Javascript."
    tagXML = sprintf("&lt;tags&gt;%s&lt;/tags&gt;", paste(sprintf("&lt;a href='%s' style='%s'%s%s%s&gt;%s&lt;/a&gt;",
        tagData$link, tagData$count, if (is.null(target))
            ""
        else sprintf(" target='%s'", target), if (is.null(tagData$color))
            ""
        else ifelse(is.na(tagData$color), sprintf(" color='0x%s'",
            tagData$color, ""), ""), if (is.null(tagData$hicolor))
            ""
        else ifelse(is.na(tagData$hicolor), sprintf(" hicolor='0x%s'",
            tagData$hicolor, ""), ""), tagData$tag), collapse = ""))
    if (useXML)
        cat(tagXML, file = file.path(dirname(htmlOutput), "tagCloud.xml"))
    cat(ifelse(scriptOnly, "",
    sprintf("&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    ?\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"&gt;
    &lt;html xmlns=\"http://www.w3.org/1999/xhtml\"&gt;
    &lt;head&gt;
    &lt;title&gt;%s&lt;/title&gt;
    &lt;meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /&gt;
    &lt;/head&gt;
    &lt;body&gt;",
        htmlTitle)), sprintf("\t&lt;script type=\"text/javascript\" src=\"%s\"&gt;&lt;/script&gt;",
        JSPath), sprintf("\t&lt;div id=\"%s\"&gt;%s&lt;/div&gt;", divId,
        noFlashJS), sprintf("\t&lt;script type=\"text/javascript\"&gt;
        \t\tvar so = new SWFObject(\"%s\", \"tagcloud\", \"%d\", \"%d\", \"%d\", \"#%s\");
        %s\t\tso.addVariable(\"mode\", \"tags\");\n\t\tso.addVariable(\"tcolor\", \"0x%s\");
        \t\tso.addVariable(\"tcolor2\", \"0x%s\");\n\t\tso.addVariable(\"hicolor\", \"0x%s\");
        \t\tso.addVariable(\"tspeed\", \"%d\");\n\t\tso.addVariable(\"distr\", \"%s\");
        %s\n\t\tso.write(\"%s\");\n\t\t&lt;/script&gt;\n",
        SWFPath, width, height, version, bgcolor, ifelse(transparent,
            "\t\tso.addParam(\"wmode\", \"transparent\");\n",
            ""), tcolor, tcolor2, hicolor, tspeed, distr, ifelse(useXML,
            "\t\tso.addVariable(\"xmlpath\", \"tagcloud.xml\");",
            sprintf("\t\tso.addVariable(\"tagcloud\", \"%s\");",
                tagXML)), divId), ifelse(scriptOnly, "", "&lt;/body&gt;\n\n&lt;/html&gt;"),
        file = ifelse(scriptOnly, stdout(), htmlOutput), sep = "\n")
}</pre>
<p>The main argument is <code>tagData</code> which is a data.frame containing at least three columns (<code>tag</code>, <code>link</code> and <code>count</code>) and looks like:</p>
<pre>&gt; head(tagData)
                tag                                        link count
1 2D Kernel Density http://yihui.name/en/tag/2d-kernel-density/     1
2         algorithm         http://yihui.name/en/tag/algorithm/     1
3         Animation         http://yihui.name/en/tag/animation/    11
4           AniWiki           http://yihui.name/en/tag/aniwiki/     2
5            Arcing            http://yihui.name/en/tag/arcing/     1
6          arrows()            http://yihui.name/en/tag/arrows/     1</pre>
<p>Additional columns <code>color</code> and <code>hicolor</code> will be used if they exist (hexadecimal numbers specifying RGB), e.g.</p>
<pre>&gt; head(tagData)
                tag                                        link count  color hicolor
1 2D Kernel Density http://yihui.name/en/tag/2d-kernel-density/     1 2163bb  f0763d
2         algorithm         http://yihui.name/en/tag/algorithm/     1 9f0f38  d825b1
3         Animation         http://yihui.name/en/tag/animation/    11 800130  5b8d6a
4           AniWiki           http://yihui.name/en/tag/aniwiki/     2 7ce1df  6607b0
5            Arcing            http://yihui.name/en/tag/arcing/     1 df4e4a  f5cdf2
6          arrows()            http://yihui.name/en/tag/arrows/     1 31f5fb  19d50d</pre>
<h1>3. Example</h1>
<p>Here is an example on visualizing my blog tags. You may need the following <code>swf</code> and <code>js</code> files first if you wish the loading would be faster (by default your browser needs to download these two files from <em>roytanck.com</em> first).</p>
<span class="download">Download the tag cloud Flash file <a href="http://yihui.name/en/wp-content/uploads/2009/06/tagcloud.swf">tagcloud.swf</a> (33.7Kb) and JavaScript <a href="http://yihui.name/en/wp-content/uploads/2009/06/swfobject.js">swfoject.js</a> (5.94Kb) as well as the data <a href="http://yihui.name/en/wp-content/uploads/2009/06/tagdata.gz">tagData.gz</a> (1.43Kb).</span>
<pre>tagCloud(tagData)
# use tagCloud(tagData, SWFPath = "tagcloud.swf", JSPath = "swfobject.js")
#    if you have downloaded these files to your work directory, i.e. getwd(),
#    this will save you a few seconds loading the flash</pre>
<p>The above code will generate an HTML page like this:<br />
<script src="http://yihui.name/en/wp-content/uploads/2009/06/swfobject.js" type="text/javascript"></script></p>
<div id="tagCloudId" style="text-align: center;">Your browser does not support Flash or Javascript!</div>
<p><script type="text/javascript"><!--
		var so = new SWFObject("http://yihui.name/en/wp-content/uploads/2009/06/tagcloud.swf", "tagcloud", "600", "400", "9", "#ffffff");
		so.addVariable("mode", "tags");
		so.addVariable("tcolor", "0x333333");
		so.addVariable("tcolor2", "0x009900");
		so.addVariable("hicolor", "0xff0000");
		so.addVariable("tspeed", "100");
		so.addVariable("distr", "true");
		so.addVariable("tagcloud", "%3ctags%3e%3ca%20href='http://yihui.name/en/tag/2d-kernel-density/'%20style='4'%20target='_blank'%20color='0x2163bb'%20hicolor='0xf0763d'%3e2D%20Kernel%20Density%3c/a%3e%3ca%20href='http://yihui.name/en/tag/algorithm/'%20style='4'%20target='_blank'%20color='0x9f0f38'%20hicolor='0xd825b1'%3ealgorithm%3c/a%3e%3ca%20href='http://yihui.name/en/tag/animation/'%20style='44'%20target='_blank'%20color='0x800130'%20hicolor='0x5b8d6a'%3eAnimation%3c/a%3e%3ca%20href='http://yihui.name/en/tag/aniwiki/'%20style='8'%20target='_blank'%20color='0x7ce1df'%20hicolor='0x6607b0'%3eAniWiki%3c/a%3e%3ca%20href='http://yihui.name/en/tag/arcing/'%20style='4'%20target='_blank'%20color='0xdf4e4a'%20hicolor='0xf5cdf2'%3eArcing%3c/a%3e%3ca%20href='http://yihui.name/en/tag/arrows/'%20style='4'%20target='_blank'%20color='0x31f5fb'%20hicolor='0x19d50d'%3earrows()%3c/a%3e%3ca%20href='http://yihui.name/en/tag/beamer/'%20style='4'%20target='_blank'%20color='0xc2acba'%20hicolor='0xb5339e'%3ebeamer%3c/a%3e%3ca%20href='http://yihui.name/en/tag/bean-machine/'%20style='4'%20target='_blank'%20color='0x38daed'%20hicolor='0x8d8cbe'%3eBean%20machine%3c/a%3e%3ca%20href='http://yihui.name/en/tag/boadilla/'%20style='4'%20target='_blank'%20color='0x286ec0'%20hicolor='0xe19caf'%3eBoadilla%3c/a%3e%3ca%20href='http://yihui.name/en/tag/book/'%20style='4'%20target='_blank'%20color='0x25ec53'%20hicolor='0xbb22df'%3eBook%3c/a%3e%3ca%20href='http://yihui.name/en/tag/boosting/'%20style='4'%20target='_blank'%20color='0xe2c060'%20hicolor='0xa1b2cc'%3eBoosting%3c/a%3e%3ca%20href='http://yihui.name/en/tag/brownian-motion/'%20style='4'%20target='_blank'%20color='0xab4709'%20hicolor='0x28e0e1'%3eBrownian%20Motion%3c/a%3e%3ca%20href='http://yihui.name/en/tag/bubble-plot/'%20style='4'%20target='_blank'%20color='0x74afe4'%20hicolor='0x79f2fa'%3eBubble%20Plot%3c/a%3e%3ca%20href='http://yihui.name/en/tag/campus/'%20style='4'%20target='_blank'%20color='0xb7eb85'%20hicolor='0x6fbb8c'%3eCampus%3c/a%3e%3ca%20href='http://yihui.name/en/tag/cluster-sampling/'%20style='4'%20target='_blank'%20color='0xb4bd58'%20hicolor='0x2800c7'%3ecluster%20sampling%3c/a%3e%3ca%20href='http://yihui.name/en/tag/coin/'%20style='4'%20target='_blank'%20color='0xa5abcf'%20hicolor='0xd4c594'%3eCoin%3c/a%3e%3ca%20href='http://yihui.name/en/tag/conan-doyle/'%20style='4'%20target='_blank'%20color='0xeabeca'%20hicolor='0x4a5814'%3eConan%20Doyle%3c/a%3e%3ca%20href='http://yihui.name/en/tag/conclusion/'%20style='4'%20target='_blank'%20color='0x331dc7'%20hicolor='0xa26978'%3eConclusion%3c/a%3e%3ca%20href='http://yihui.name/en/tag/confidence-interval/'%20style='4'%20target='_blank'%20color='0x6f0a88'%20hicolor='0x7b0126'%3eConfidence%20Interval%3c/a%3e%3ca%20href='http://yihui.name/en/tag/convergence/'%20style='4'%20target='_blank'%20color='0x095f1c'%20hicolor='0x90568e'%3eConvergence%3c/a%3e%3ca%20href='http://yihui.name/en/tag/covariance/'%20style='4'%20target='_blank'%20color='0x2880e3'%20hicolor='0x9c530e'%3eCovariance%3c/a%3e%3ca%20href='http://yihui.name/en/tag/flash/'%20style='8'%20target='_blank'%20color='0xb3f222'%20hicolor='0x1b76bc'%3eFlash%3c/a%3e%3ca%20href='http://yihui.name/en/tag/gradient-descent/'%20style='8'%20target='_blank'%20color='0xbdf2d4'%20hicolor='0x7cd201'%3eGradient%20Descent%3c/a%3e%3ca%20href='http://yihui.name/en/tag/graphics/'%20style='32'%20target='_blank'%20color='0x6ea48d'%20hicolor='0x29a816'%3eGraphics%3c/a%3e%3ca%20href='http://yihui.name/en/tag/highlight/'%20style='8'%20target='_blank'%20color='0x59508e'%20hicolor='0x6d5de6'%3eHighlight%3c/a%3e%3ca%20href='http://yihui.name/en/tag/hypothesis-test/'%20style='8'%20target='_blank'%20color='0x7b88bb'%20hicolor='0xabc9f8'%3eHypothesis%20Test%3c/a%3e%3ca%20href='http://yihui.name/en/tag/image/'%20style='8'%20target='_blank'%20color='0x06ac63'%20hicolor='0x92614f'%3eimage()%3c/a%3e%3ca%20href='http://yihui.name/en/tag/interaction/'%20style='8'%20target='_blank'%20color='0xd8dbce'%20hicolor='0x44f1a4'%3eInteraction%3c/a%3e%3ca%20href='http://yihui.name/en/tag/joke/'%20style='8'%20target='_blank'%20color='0xa68ed9'%20hicolor='0x4dc5a7'%3eJoke%3c/a%3e%3ca%20href='http://yihui.name/en/tag/jokes/'%20style='8'%20target='_blank'%20color='0x2f18ca'%20hicolor='0x034e9c'%3eJokes%3c/a%3e%3ca%20href='http://yihui.name/en/tag/latex/'%20style='20'%20target='_blank'%20color='0x8cb56a'%20hicolor='0x4b3de1'%3eLaTeX%3c/a%3e%3ca%20href='http://yihui.name/en/tag/line-break/'%20style='8'%20target='_blank'%20color='0xdfd52a'%20hicolor='0xb328c7'%3eline%20break%3c/a%3e%3ca%20href='http://yihui.name/en/tag/map/'%20style='8'%20target='_blank'%20color='0x3b64b9'%20hicolor='0x13e24e'%3eMap%3c/a%3e%3ca%20href='http://yihui.name/en/tag/model/'%20style='12'%20target='_blank'%20color='0x573218'%20hicolor='0xf98a0e'%3eModel%3c/a%3e%3ca%20href='http://yihui.name/en/tag/mouse/'%20style='8'%20target='_blank'%20color='0xc6420f'%20hicolor='0xcce772'%3eMouse%3c/a%3e%3ca%20href='http://yihui.name/en/tag/new-year/'%20style='8'%20target='_blank'%20color='0x3d0906'%20hicolor='0xe3ff6d'%3eNew%20Year%3c/a%3e%3ca%20href='http://yihui.name/en/tag/parse/'%20style='8'%20target='_blank'%20color='0x1387a6'%20hicolor='0x848ea2'%3eparse()%3c/a%3e%3ca%20href='http://yihui.name/en/tag/pdf/'%20style='12'%20target='_blank'%20color='0x6b97b1'%20hicolor='0x5855be'%3epdf()%3c/a%3e%3ca%20href='http://yihui.name/en/tag/plugin/'%20style='8'%20target='_blank'%20color='0x33942f'%20hicolor='0x77ab96'%3eplugin%3c/a%3e%3ca%20href='http://yihui.name/en/tag/random-number-generator/'%20style='8'%20target='_blank'%20color='0xa6e5cb'%20hicolor='0x1cdf76'%3eRandom%20Number%20Generator%3c/a%3e%3ca%20href='http://yihui.name/en/tag/r-code/'%20style='16'%20target='_blank'%20color='0x9f6dca'%20hicolor='0x3af938'%3eR%20code%3c/a%3e%3ca%20href='http://yihui.name/en/tag/r-language/'%20style='48'%20target='_blank'%20color='0x6b3da1'%20hicolor='0x606774'%3eR%20Language%3c/a%3e%3ca%20href='http://yihui.name/en/tag/r-package/'%20style='20'%20target='_blank'%20color='0x2683f4'%20hicolor='0x67bbc4'%3eR%20Package%3c/a%3e%3ca%20href='http://yihui.name/en/tag/statistical-analysis/'%20style='8'%20target='_blank'%20color='0x2f1125'%20hicolor='0xaa5142'%3eStatistical%20Analysis%3c/a%3e%3ca%20href='http://yihui.name/en/tag/web-site/'%20style='8'%20target='_blank'%20color='0x6ca810'%20hicolor='0x2374b4'%3eweb%20site%3c/a%3e%3c/tags%3e");
		so.write("tagCloudId");
// --></script><br />
You can adjust the parameters as you wish.</p>
<h1>4. Other issues</h1>
<p>There is still one more step to answer Tony&#8217;s original question, namely splitting the speech into single words and computing the frequency. This can be (roughly) done by <code>strsplit(..., split = " ")</code> and <code>table()</code>.</p>
<p>Encoding problems may exist in the above code, but <code>URLencode(tagXML)</code> could be of help.</p>
<p>Only Latin characters are supported, but there&#8217;s possibility to modify the Flash source file to support other languages. See <a href="http://www.roytanck.com/2008/03/15/wp-cumulus-released/" target="_blank">Roy Tanck&#8217;s post</a> for more information.</p>
<p>Other R resources I know so far:</p>
<ul>
<li>The R package <a title="R4X package" href="http://r-forge.r-project.org/projects/r4x/" target="_blank"><code>R4X</code></a> by <a title="Blog" href="http://romainfrancois.blog.free.fr" target="_blank">Romain Fran?ois</a>: you can generate an HTML page containing the tags with <em>dynamic</em> classes attached to the <code>&lt;span&gt;</code> tags (install the package and read its vignette: <code>install.packages('R4X', repos='http://r-forge.r-project.org'); vignette('r4xslides', package='R4X')</code>)</li>
<li>The R package <a title="package snippets" href="http://www.rforge.net/snippets/" target="_blank"><code>snippets</code></a> by <a title="Homepage" href="http://simon.urbanek.info/" target="_blank">Simon Urbanek</a>: there is a function <code>cloud()</code> to create word cloud; words are arranged from top to bottom and left to right</li>
</ul>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://yihui.name/en/2009/12/happy-new-year-with-r/" title="Happy New Year with R">Happy New Year with R</a></li><li><a href="http://yihui.name/en/2009/12/merry-christmas-using-r/" title="Merry Christmas Using R">Merry Christmas Using R</a></li><li><a href="http://yihui.name/en/2009/06/simulation-of-burning-fire-in-r/" title="Simulation of Burning Fire in R">Simulation of Burning Fire in R</a></li><li><a href="http://yihui.name/en/2010/08/auto-completion-in-notepad-for-r-script/" title="Auto-completion in Notepad++ for R Script">Auto-completion in Notepad++ for R Script</a></li><li><a href="http://yihui.name/en/2010/04/r-is-an-epic-fail/" title="R is an Epic Fail?">R is an Epic Fail?</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://yihui.name/en/2009/06/creating-tag-cloud-using-r-and-flash-javascript-swfobject/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
	</channel>
</rss>
