<?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>Marios Braindump &#187; R</title>
	<atom:link href="http://www.mfasold.net/blog/tag/r/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mfasold.net/blog</link>
	<description>Just shouting my thoughts out</description>
	<lastBuildDate>Fri, 23 Jul 2010 14:21:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Latticist Package for R</title>
		<link>http://www.mfasold.net/blog/2010/07/the-latticist-package-for-r/</link>
		<comments>http://www.mfasold.net/blog/2010/07/the-latticist-package-for-r/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 14:21:16 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[research]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=435</guid>
		<description><![CDATA[One of my dear readers, C S,  has pointed out to me the R package latticist. In the beginning I was sceptical, since the package is merely more than an interface to existing visualization routines. However, I now consider it astonishingly useful and use it almost every day. The reason is simple: Getting an intial [...]]]></description>
			<content:encoded><![CDATA[<p>One of my dear readers, <a href="http://r-chart.blogspot.com/">C S</a>,  has pointed out to me the R package <a href="http://code.google.com/p/latticist/">latticist</a>. In the beginning I was sceptical, since the package is merely more than an interface to existing visualization routines. However, I now consider it astonishingly useful and use it almost every day. The reason is simple: Getting an intial glimpse onto a large set of multivariate data is tedious in R, due to the command line interface. With latticist, you get an instant overview over all variables of interest and it allows you to quickly dive into details by selecting subgroups and to look at potential correlations. Recommended.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2010/07/the-latticist-package-for-r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline Figures in Org-Mode Paper Drafts</title>
		<link>http://www.mfasold.net/blog/2009/07/inline-figures-in-org-mode-paper-drafts/</link>
		<comments>http://www.mfasold.net/blog/2009/07/inline-figures-in-org-mode-paper-drafts/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 13:46:43 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[science]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=315</guid>
		<description><![CDATA[Writing a paper often comes along with a problem known as information fragmentation: figures, tables and the respective data sources related to the paper certainly are somewhere on your hard disk &#8211; but where? How did I name the file with the data-points again? And, the heck, which commands did I use to create that [...]]]></description>
			<content:encoded><![CDATA[<p>Writing a paper often comes along with a problem known as information fragmentation: figures, tables and the respective data sources related to the paper certainly are somewhere on your hard disk &#8211; but where? How did I name the file with the data-points again? And, the heck, which commands did I use to create that fancy plot? But chill, there is a way to avoid the joyless seeking and re-finding. At least if you <a href="http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/">draft your papers in org-mode</a>, as I described in a recent post.</p>
<p><span id="more-315"></span>The key tool here is the wonderful org-mode extension Org-R by Dan Davison. It allows to include code fragments that create figures or tables directly into your document. That way, everything will be in one place.  Searching, au revoir.</p>
<p><strong>Introduction to Org-R</strong></p>
<p>Luckily, Dan wrote a <a href="http://orgmode.org/worg/org-tutorials/org-R/org-R.php">comprehensive tutorial</a> on how to use org-R. If your planning to give it a try, I suggest to look over his words first. However, he forgot to mention two things you&#8217;ll need to enable the org-R goodness. Insert</p>
<blockquote><p>(add-to-list &#8216;load-path &#8220;~/site-lisp/org-mode/contrib/lisp&#8221;)<br />
(require &#8216;org-R)</p></blockquote>
<p>into your .emacs and edit the directory to point into your org-mode directory. Also, you need to have a R instance running (invoke <code>M-x R</code>) in the directory of your document. Try some of the examples given in his tutorial in a new .org document now.</p>
<p>What happens behind the scenes here is that org-R translates the inline commands into a R command sequence. For example, <code>infile:x.csv</code> is converted into <code>x = read.table(...)</code> . The <code>+RR</code> prefix introduces direct R commands, which are executed before the <code>+R</code> commands (except infile:). The result is then inserted as a table or as a link to a graphic. Note that many actions rely on conventions:  <code>outfile:x.png</code> will create a png image. Reading from a datafile will only work if the file suffix is .csv. And its contents will always be stored in a variable x. If you are not sure what is happening behind the scenes, the command <code>showcode:t</code> shows you the created R-code and is hence a great tool for debugging.</p>
<p><strong>Using figures</strong></p>
<p>A typical fragment for creating a figure that is also exported into LaTeX/PDF/HTML properly is</p>
<blockquote><p>#+CAPTION: Distribution of foot sizes among coputer scientists<br />
#+LABEL: fig:SizeDistribution<br />
#+ATTR_LaTeX: scale=0.5<br />
[[file:images/distanceDist.png]]<br />
#+R: infile:&#8221;tmp.csv&#8221; #+R: action:density columns:1 args:(:lwd 4)<br />
#+R: outfile:&#8221;images/distanceDist.png&#8221;<br />
#+R: inline:t</p></blockquote>
<p>The first three lines give the image a caption and a reference, and define the size of the image in the paper. Invoking C-c (or <code>org-apply</code>) in the second part will (re-)create the image. The command <code>#+R: inline:t</code> is required for the resulting link to the image having the same format as the LaTeX exporter recognizes for figures.</p>
<p><strong>Keeping your document clean</strong></p>
<p>The main intend of org-R obviously was to enable org-mode users to perform quick calculations and create simple graphs from data that originates from org-tables. Undeniable, org-r is very good at that. However, our objective shall rather be to centralize and de-fragment drafting of papers containing complex figures. When it comes to more elaborate graphs and datasets, the usefulness of  the predefined actions vanishes and longer, more complex R code is required. You might rather want to work in ESS/R-mode, where you have all the coloring and intendation niceness, and you do not have to precede every line with an +RR:.</p>
<p>The alternative is to source the functions from a separate .R file, for example you could use</p>
<blockquote><p>#+CAPTION: Distribution of finger lengths among computer scientists<br />
#+ATTR_LaTeX: scale=0.5<br />
#+LABEL: fig:LengthDistribution<br />
[[file:images/distanceDist.png]]<br />
#+R: infile:&#8221;tmp.csv&#8221;<br />
#+RR: source(&#8221;rcode.R&#8221;)<br />
#+RR: myDensity(x)<br />
#+R: outfile:&#8221;images/distanceDist.png&#8221;<br />
#+R: inline:t</p></blockquote>
<p>with the following code (imagine a longer fragment) in rcode.R</p>
<blockquote><p>myDensity &lt;- function(x) {  <br />
    plot(density(x[,1]), col=&#8221;chartreuse4&#8243;, lwd=5, xlim=c(0,2000))<br />
}</p></blockquote>
<p>That way, you avoid immense R code pollution in your draft, yet you have all the information (data-files, linked code and parameters) in one place. Happy drafting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2009/07/inline-figures-in-org-mode-paper-drafts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Directly Edit and Play with Plots in R</title>
		<link>http://www.mfasold.net/blog/2009/01/edit-and-play-with-plots/</link>
		<comments>http://www.mfasold.net/blog/2009/01/edit-and-play-with-plots/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 15:22:10 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=238</guid>
		<description><![CDATA[The R-project describes itself as a &#8220;free software environment for statistical computing and graphics&#8221;. It can produce nice graphics indeed, but in practice editing them often gets tedious since any alteration must be given as one or multiple command-line commands. At least I thought so &#8211; until I found out about the playwith package. With [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.r-project.org/">R-project</a> describes itself as a &#8220;free software environment for statistical computing and graphics&#8221;. It can produce nice graphics indeed, but in practice editing them often gets tedious since any alteration must be given as one or multiple command-line commands. At least I thought so &#8211; until I found out about the <em>playwith</em> package. With it, you can play with any kind of graphic (plots, histograms, images&#8230;) interactively: zoom in/out, add text, modify colors and more. You can even add input elements (sliders, buttons,&#8230;) to interactively control any variable you&#8217;re using. The resulting graphics can be exported directly (hint: set output format with <code>playwith.options(save.as.format = "svg")</code> ). Try the package out: <a href="http://code.google.com/p/playwith/">Playwith at Google Code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2009/01/edit-and-play-with-plots/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a R-GUI in the wink of an eye</title>
		<link>http://www.mfasold.net/blog/2008/12/creating-a-r-gui/</link>
		<comments>http://www.mfasold.net/blog/2008/12/creating-a-r-gui/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 13:08:23 +0000</pubDate>
		<dc:creator>Mario</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[science]]></category>

		<guid isPermaLink="false">http://www.mfasold.net/blog/?p=204</guid>
		<description><![CDATA[I think many folks have been waiting for this. R is a statistical language widely established itself in the life-sciences. However, many lab people dislike it due to its bare commandline interface. This might change with a new program called RGG:
Self written R scripts are usually not longer than 100-150 lines. In most cases, there [...]]]></description>
			<content:encoded><![CDATA[<p>I think many folks have been waiting for this. R is a statistical language widely established itself in the life-sciences. However, many lab people dislike it due to its bare commandline interface. This might change with a new program called <a href="http://rgg.r-forge.r-project.org/">RGG</a>:</p>
<blockquote><p>Self written R scripts are usually not longer than 100-150 lines. In most cases, there are 5-10 code items, that the user needs to change often, like setting the working directory, reading an input file, setting parameters to new values etc. The rest of the code usually remains unchanged.</p>
<p>For this problem we have developed a solution: &#8220;R GUI Generator (RGG)&#8221;. RGG is a GUI generator for R scripts based on a GUI definition language in XML. A GUI is generated by adding predefined GUI tags to the R script. User-GUI interactions are converted to R code, which replace the xml-tags in the R script.</p></blockquote>
<p>This sounds quite promising, doesn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mfasold.net/blog/2008/12/creating-a-r-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
