<?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>R-statistics blogR-statistics blog</title>
	<atom:link href="http://www.r-statistics.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.r-statistics.com</link>
	<description>Writing about statistics with R, and open source stuff (software, data, community)</description>
	<lastBuildDate>Mon, 20 May 2013 15:26:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<div id='fb-root'></div>
					<script type='text/javascript'>
						window.fbAsyncInit = function()
						{
							FB.init({appId: null, status: true, cookie: true, xfbml: true});
						};
						(function()
						{
							var e = document.createElement('script'); e.async = true;
							e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
							document.getElementById('fb-root').appendChild(e);
						}());
					</script>	
						<item>
		<title>R 3.0.1 is released</title>
		<link>http://www.r-statistics.com/2013/05/r-3-0-1-is-released/</link>
		<comments>http://www.r-statistics.com/2013/05/r-3-0-1-is-released/#comments</comments>
		<pubDate>Mon, 20 May 2013 14:37:54 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[3.0.1]]></category>
		<category><![CDATA[installr]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[R 3.0.1]]></category>
		<category><![CDATA[upgrading R]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60995</guid>
		<description><![CDATA[R 3.0.1 (codename &#8220;Good Sport&#8221;) was released last week. As mentioned earlier by David, this version improves serialization performance with big objects, improves reliability for parallel programming and fixes a few minor bugs. Upgrading to R 3.0.1 You can download &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/05/r-3-0-1-is-released/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/05/r-3-0-1-is-released/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>R 3.0.1 (codename &#8220;Good Sport&#8221;) was <a href="https://stat.ethz.ch/pipermail/r-announce/2013/000563.html">released last week</a>. As <a href="http://blog.revolutionanalytics.com/2013/05/r-301-released.html" target="_blank">mentioned earlier</a> by David, this version improves serialization performance with big objects, improves reliability for parallel programming and fixes a few minor bugs.</p>
<h3>Upgrading to R 3.0.1</h3>
<p>You can download the latest version <a href="http://cran.rstudio.com/" target="_blank">from here</a>. Or, if you are using windows, you can upgrade to the latest version using <a href="http://www.r-statistics.com/tag/installr/" target="_blank">the installr package</a> (also available <a href="http://cran.r-project.org/web/packages/installr/" target="_blank">on CRAN</a> and <a href="https://github.com/talgalili/installr/" target="_blank">github</a>). Simply run the following code:</p>

<div class="wp_codebox"><table><tr id="p609953"><td class="code" id="p60995code3"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> 
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
&nbsp;
updateR<span style="color: #080;">&#40;</span>to_checkMD5sums <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># the use of to_checkMD5sums is because of a slight bug in the MD5 file on R 3.0.1. Soon this should get resolved and you could go back to using updateR(), install.R() or the menu upgrade system.</span></pre></td></tr></table></div>

<p>I try to keep the installr package updated and useful. If you have any suggestions or remarks on the package, you&#8217;re invited to leave a comment below.</p>
<p>If you use the <a href="http://www.r-statistics.com/2010/04/changing-your-r-upgrading-strategy-and-the-r-code-to-do-it-on-windows/">global library</a> system (as I do), you can run the following in the new version of R:</p>

<div class="wp_codebox"><table><tr id="p609954"><td class="code" id="p60995code4"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">source</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;http://www.r-statistics.com/wp-content/uploads/2010/04/upgrading-R-on-windows.r.txt&quot;</span><span style="color: #080;">&#41;</span>
New.<span style="">R</span>.<span style="">RunMe</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p><span id="more-60995"></span></p>
<h3>R 3.0.1 NEWS:</h3>
<pre>This is the relevant part of the NEWS file

CHANGES IN R 3.0.1:

  NEW FEATURES:

    o chooseCRANmirror() and chooseBioCmirror() gain an ind argument
      (like setRepositories()).

    o mcparallel has a new argument mc.interactive which can modify the
      interactive flag in the child process. The new default is FALSE
      which makes child processes non-interactive by default (this
      prevents lock-ups due to children waiting for interactive input).

    o scan() now warns when end-of-file occurs within a quoted string.

    o count.fields() is now consistent with scan() in its handling of
      newlines in quoted strings.  Instead of triggering an error, this
      results in the current line receiving NA as the field count, with
      the next line getting the total count of the two lines.

    o The default method of image() will plot axes of the class of xlim
      and ylim (and hence of x and y if there is a suitable range()
      method).  Based on a suggestion of Michael Sumner.

    o load() now has a verbose argument for debugging support, to print
      the names of objects just before loading them.

    o When loading a serialized object encounters a reference to a
      namespace which cannot be loaded, this is replaced by a reference
      to the global environment, with a warning.

    o pairs() gains a line.main option for title placement.

    o The remaining instances in which serialization to a raw vector
      was limited to 2GB have been unlimited on a 64-bit platform, and
      in most cases serialization to a vector of more than 1GB will be
      substantially faster.

  UTILITIES:

    o R CMD config now make use of personal Makevars files under ~/.R
      and a site file Makevars.site, in the same way as R CMD SHLIB and
      R CMD INSTALL.  This makes the utility more useful in package
      configure scripts.

      On Windows finding the personal files may require the environment
      variable HOME set.

      The old behaviour can be obtained with the new options
      --no-user-files and --no-site-files.

  PACKAGE INSTALLATION:

    o Alternatives to the site and user customization files
      Makevars.site and ~/.R/Makevars can be specified _via_ the
      environment variables R_MAKEVARS_SITE and R_MAKEVARS_USER
      respectively.  These can be used to suppress the use of the
      default files by setting an empty value (where possible) or a
      non-existent path.

  BUG FIXES:

    o sys.source() did not report error locations when keep.source =
      TRUE.

    o as.POSIXct.numeric was coercing origin using the tz argument and
      not "GMT" as documented (PR#14973).

    o The active binding to assign fields in reference classes has been
      cleaned up to reduce dependence on the class' package
      environment, also fixing bug in initializing read-only fields
      (inspired by a report from Hadley Wickham).

    o str(d) no longer gives an error when names(d) contain illegal
      multibyte strings (PR#15247).

    o Profiling of built-in functions with line.profiling= TRUE did not
      record the line from which they were called.

    o citation(pkg) dropped the header and footer specified in the
      CITATION file (PR#15257).

    o Quotes were handled differently when reading the first line and
      reading the rest, so read.table() misread some files that
      contained quote characters (PR#15245).

    o cat() with sep a character vector of length greater than one and
      more than one argument was using separators inconsistently
      (PR#15261).

    o On Windows in R 3.0.0, savePlot() failed because of an incorrect
      check on the argument count.

    o unzip(list = TRUE) returned Names as a factor and not a character
      vector (as documented) for the internal method.  (Noticed by Sean
      O'Riordain.)

    o contourLines() now checks more comprehensively for conformance of
      its x, y and z arguments (it was used incorrectly in package
      R2G2).

    o Saved graphics display lists are R version-specific.  Attempting
      to load workspaces containing them (or some other
      version-specific objects) aborted the load in R 3.0.0 and
      earlier; now it does a partial load and generates a warning
      instead.

    o In R 3.0.0, identify() and locator() did not record information
      correctly, so replaying a graph (e.g. by copying it to another
      device) would fail. (PR#15271)

    o Calling file.copy() or dirname() with the invalid input "" (which
      was being used in packages, despite not being a file path) could
      have caused a segfault.

      dirname("") is now "" rather than "." (unless it segfaulted).

    o supsmu() could read/write outside its input vectors for very
      short inputs (seen in package rms for n = 4).

    o as.dendrogram()'s hclust method uses less memory and hence gets
      considerably faster for large (n ~ 1000) clusterings, thanks to
      Daniel M"ullner. (PR#15174)

    o The return value when all workers failed from
      parallel::mclapply(mc.presechedule = TRUE) was a list of strings
      and not of error objects.  (Spotted by Karl Forner and Bernd
      Bischl.)

    o In R 3.0.0, when help() found multiple pages with the same alias,
      the HTML display of all the selections was not produced.
      (PR#15282)

    o splinefun(method="monoH.FC") now produces a function with first
      argument named x and allows deriv=3, as documented. (PR#15273)

    o summaryRprof() would only read the first chunksize lines of an
      Rprof file produced with line.profiling=TRUE. By default, this is
      the first 100 seconds.  (PR#15288)

    o lsfit() produced an incorrect error message when argument x had
      more columns than rows or x had a different number of rows than
      y. (Spotted by Renaud Gaujoux.)

    o Binary operations on equal length vectors copied the class name
      from the second operand when the first had no class name, but did
      not set the object bit. (PR#15299)

    o The trace() method for reference generator objects failed after
      those objects became function definitions.

    o write.table() did not check that factors were constructed
      correctly, and so caused a segment fault when writing bad ones.
      (PR#15300)

    o The internal HTTP server no longer chokes on POST requests
      without body. It will also pass-through other request types for
      custom handlers (with the method stored in Request-Method header)
      instead of failing.</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/05/r-3-0-1-is-released/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/05/r-3-0-1-is-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R 3.0.0 is released! (what&#8217;s new, and how to upgrade)</title>
		<link>http://www.r-statistics.com/2013/04/r-3-0-0-is-released-whats-new-and-how-to-upgrade/</link>
		<comments>http://www.r-statistics.com/2013/04/r-3-0-0-is-released-whats-new-and-how-to-upgrade/#comments</comments>
		<pubDate>Wed, 03 Apr 2013 13:28:20 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R community]]></category>
		<category><![CDATA[installr]]></category>
		<category><![CDATA[R 3.0.0]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60982</guid>
		<description><![CDATA[A few hours ago Peter Dalgaard (of R Core Team) announced the release of R 3.0.0!  Bellow you can read the changes in this release. One of the features worth noticing is the introduction of long vectors to R 3.0.0. As David Smith &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/04/r-3-0-0-is-released-whats-new-and-how-to-upgrade/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/04/r-3-0-0-is-released-whats-new-and-how-to-upgrade/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>A few hours ago Peter Dalgaard (of R Core Team) announced the release of R 3.0.0!  Bellow you can read the changes in this release.</p>
<p>One of the features worth noticing is the introduction of long vectors to R 3.0.0. As <a href="http://blog.revolutionanalytics.com/2013/01/r-version-3-scheduled-for-april.html" target="_blank">David Smith recently wrote</a>:</p>
<blockquote><p>Although many people won&#8217;t notice the difference, the <a href="http://blog.revolutionanalytics.com/2012/07/big-vectors-coming-to-r.html" target="_self">introduction of long vectors to R</a> is in fact a significant upgrade, and required a lot of work behind-the-scenes to implement in the core R engine. It will allow data frames to exceed their current 2 billion row limit, and in general allow R to make better use of memory in systems with large amounts of RAM. Many thanks go to the R core team for making this improvement.</p></blockquote>
<p>You can get the source code from:  <a href="http://cran.r-project.org/src/base/R-3/R-3.0.0.tar.gz" target="_blank">http://cran.r-project.org/src/<wbr />base/R-3/R-3.0.0.tar.gz</a></p>
<p>or wait for it to be mirrored at a CRAN site nearer to you. Binaries for various platforms will appear in due course (which often means it will be within the next 2-48 hours).</p>
<p>If you are running R on <strong>Ubuntu</strong>, you may wish to consult <a href="http://www.personal.psu.edu/mar36/blogs/the_ubuntu_r_blog/2013/03/moving-to-r-300-on-ubuntu.html" target="_blank">this post</a>.</p>
<p>If you are running R on <strong>Windows</strong>, you can use the following code to quickly download and install the latest R version using <a href="http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/" target="_blank">the <em>installr</em> package</a>:</p>

<div class="wp_codebox"><table><tr id="p609827"><td class="code" id="p60982code7"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> 
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
install.<span style="">R</span><span style="color: #080;">&#40;</span>to_checkMD5sums <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span> <span style="color: #228B22;"># the use of to_checkMD5sums is because of a slight bug in the MD5 file on R 3.0.0. Soon this should get resolved and you could go back to using updateR()</span></pre></td></tr></table></div>

<p>Either way, all users should note that this new release requires that packages will need to be re-installed, which means that after you install the new R, you should run the following command in it:</p>

<div class="wp_codebox"><table><tr id="p609828"><td class="code" id="p60982code8"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">update.<span style="">packages</span></span><span style="color: #080;">&#40;</span>checkBuilt<span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>(thank to Prof. Ripley for the above clarification, and <a href="http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f" target="_blank">the FAQ pointer</a>)</p>
<h3>R 3.0.0 NEWS:</h3>
<h4>SIGNIFICANT USER-VISIBLE CHANGES</h4>
<p><span id="more-60982"></span></p>
<ul>
<li><strong>Packages need to be (re-)installed under this version (3.0.0) of R.</strong></li>
<li>There is a subtle change in behaviour for numeric index values <i>2^31</i> and larger. These never used to be legitimate and so were treated as <code>NA</code>, sometimes with a warning. They are now legal for long vectors so there is no longer a warning, and <code>x[2^31] &lt;- y</code> will now extend the vector on a 64-bit platform and give an error on a 32-bit one.</li>
<li>It is now possible for 64-bit builds to allocate amounts of memory limited only by the OS. It may be wise to use OS facilities (e.g.<code>ulimit</code> in a <code>bash</code> shell, <code>limit</code> in <code>csh</code>), to set limits on overall memory consumption of an <b>R</b> process, particularly in a multi-user environment. A number of packages need a limit of at least 4GB of virtual memory to load.64-bit Windows builds of <b>R</b> are by default limited in memory usage to the amount of RAM installed: this limit can be changed by command-line option &#8211;max-mem-size or setting environment variable R_MAX_MEM_SIZE.</li>
<li>Negative numbers for colours are consistently an error: previously they were sometimes taken as transparent, sometimes mapped into the current palette and sometimes an error.</li>
</ul>
<h4>NEW FEATURES</h4>
<ul>
<li><code>identical()</code> has a new argument, <code>ignore.environment</code>, used when comparing functions (with default <code>FALSE</code> as before).</li>
<li>There is a new option, <code>options(CBoundsCheck=)</code>, which controls how <code>.C()</code> and <code>.Fortran()</code> pass arguments to compiled code. If true (which can be enabled by setting the environment variable R_C_BOUNDS_CHECK to yes), raw, integer, double and complex arguments are always copied, and checked for writing off either end of the array on return from the compiled code (when a second copy is made). This also checks individual elements of character vectors passed to <code>.C()</code>.This is not intended for routine use, but can be very helpful in finding segfaults in package code.</li>
<li>In <code>layout()</code>, the limits on the grid size have been raised (again).</li>
<li>New simple <code>provideDimnames()</code> utility function.</li>
<li>Where methods for <code>length()</code> return a double value which is representable as an integer (as often happens for package <a href="http://cran.r-project.org/package=Matrix">Matrix</a>), this is converted to an integer.</li>
<li>Matrix indexing of dataframes by two-column numeric indices is now supported for replacement as well as extraction.</li>
<li><code>setNames()</code> now has a default for its <code>object</code> argument, useful for a character result.</li>
<li><code>StructTS()</code> has a revised additive constant in the <code>loglik</code> component of the result: the previous definition is returned as the <code>loglik0</code>component. However, the help page has always warned of a lack of comparability of log-likelihoods for non-stationary models. (Suggested by Jouni Helske.)</li>
<li>The logic in <code>aggregate.formula()</code> has been revised. It is now possible to use a formula stored in a variable; previously, it had to be given explicitly in the function call.</li>
<li><code>install.packages()</code> has a new argument <code>quiet</code> to reduce the amount of output shown.</li>
<li>Setting an element of the graphics argument <code>lwd</code> to a negative or infinite value is now an error. Lines corresponding to elements with values <code>NA</code> or <code>NaN</code> are silently omitted.Previously the behaviour was device-dependent.</li>
<li>Setting graphical parameters <code>cex</code>, <code>col</code>, <code>lty</code>, <code>lwd</code> and <code>pch</code> in <code>par()</code> now requires a length-one argument. Previously some silently took the first element of a longer vector, but not always when documented to do so.</li>
<li><code>Sys.which()</code> when used with inputs which would be unsafe in a shell (e.g. absolute paths containing spaces) now uses appropriate quoting.</li>
<li><code>as.tclObj()</code> has been extended to handle raw vectors. Previously, it only worked in the other direction. (Contributed by Charlie Friedemann, <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14939">PR#14939</a>.)</li>
<li>New functions <code>cite()</code> and <code>citeNatbib()</code> have been added, to allow generation of in-text citations from <code>"bibentry"</code> objects. A<code>cite()</code> function may be added to <code>bibstyle()</code> environments.</li>
<li>A <code>sort()</code> method has been added for <code>"bibentry"</code> objects.</li>
<li>The <code>bibstyle()</code> function now defaults to setting the default bibliography style. The <code>getBibstyle()</code> function has been added to report the name of the current default style.</li>
<li><code>scatter.smooth()</code> now has an argument <code>lpars</code> to pass arguments to <code>lines()</code>.</li>
<li><code>pairs()</code> has a new <code>log</code> argument, to allow some or all variables to be plotted on logarithmic scale. (In part, wish of <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14919">PR#14919</a>.)</li>
<li><code>split()</code> gains a <code>sep</code> argument.</li>
<li><code>termplot()</code> does a better job when given a model with interactions (and no longer attempts to plot interaction terms).</li>
<li>The parser now incorporates code from Romain Francois&#8217; <a href="http://cran.r-project.org/package=parser">parser</a> package, to support more detailed computation on the code, such as syntax highlighting, comment-based documentation, etc. Functions <code>getParseData()</code> and <code>getParseText()</code> access the data.</li>
<li>There is a new function <code>rep_len()</code> analogous to <code>rep.int()</code> for when speed is required (and names are not).</li>
<li>The undocumented use <code>rep(NULL, length.out = n)</code> for <code>n &gt; 0</code> (which returns <code>NULL</code>) now gives a warning.</li>
<li><code>demo()</code> gains an <code>encoding</code> argument for those packages with non-ASCII demos: it defaults to the package encoding where there is one.</li>
<li><code>strwrap()</code> converts inputs with a marked encoding to the current locale: previously it made some attempt to pass through as bytes inputs invalid in the current locale.</li>
<li>Specifying both <code>rate</code> and <code>scale</code> to <code>[dpqr]gamma</code> is a warning (if they are essentially the same value) or an error.</li>
<li><code>merge()</code> works in more cases where the data frames include matrices. (Wish of <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14974">PR#14974</a>.)</li>
<li><code>optimize()</code> and <code>uniroot()</code> no longer use a shared parameter object across calls. (<code>nlm()</code>, <code>nlminb()</code> and <code>optim()</code> with numerical derivatives still do, as documented.)</li>
<li>The <code>all.equal()</code> method for date-times is now documented: times are regarded as equal (by default) if they differ by up to 1 msec.</li>
<li><code>duplicated()</code> and <code>unique()</code> gain a <code>nmax</code> argument which can be used to make them much more efficient when it is known that there are only a small number of unique entries. This is done automatically for factors.</li>
<li>Functions <code>rbinom()</code>, <code>rgeom()</code>, <code>rhyper()</code>, <code>rpois()</code>, <code>rnbinom(),</code> <code>rsignrank()</code> and <code>rwilcox()</code> now return integer (not double) vectors. This halves the storage requirements for large simulations.</li>
<li><code>sort()</code>, <code>sort.int()</code> and <code>sort.list()</code> now use radix sorting for factors of less than 100,000 levels when <code>method</code> is not supplied. So does <code>order()</code> if called with a single factor, unless <code>na.last = NA</code>.</li>
<li><code>diag()</code> as used to generate a diagonal matrix has been re-written in C for speed and less memory usage. It now forces the result to be numeric in the case <code>diag(x)</code> since it is said to have ‘zero off-diagonal entries’.</li>
<li><code>backsolve()</code> (and <code>forwardsolve()</code>) are now internal functions, for speed and support for large matrices.</li>
<li>More matrix algebra functions (e.g. <code>chol()</code> and <code>solve()</code>) accept logical matrices (and coerce to numeric).</li>
<li><code>sample.int()</code> has some support for <i>n &gt;= 2^31</i>: see its help for the limitations.A different algorithm is used for <code>(n, size, replace = FALSE, prob = NULL)</code> for <code>n &gt; 1e7</code> and <code>size &lt;= n/2</code>. This is much faster and uses less memory, but does give different results.</li>
<li><code>approxfun()</code> and <code>splinefun()</code> now return a wrapper to an internal function in the stats namespace rather than a <code>.C()</code> or <code>.Call()</code>call. This is more likely to work if the function is saved and used in a different session.</li>
<li>The functions <code>.C()</code>, <code>.Call()</code>, <code>.External()</code> and <code>.Fortran()</code> now give an error (rather than a warning) if called with a named first argument.</li>
<li><code>Sweave()</code> by default now reports the locations in the source file(s) of each chunk.</li>
<li><code>clearPushBack()</code> is now a documented interface to a long-existing internal call.</li>
<li><code>aspell()</code> gains filters for <b>R</b> code, Debian Control Format and message catalog files, and support for <b>R</b> level dictionaries. In addition, package utils now provides functions <code>aspell_package_R_files()</code> and <code>aspell_package_C_files()</code> for spell checking <b>R</b> and C level message strings in packages.</li>
<li><code>bibentry()</code> gains some support for “incomplete” entries with a crossref field.</li>
<li><code>gray()</code> and <code>gray.colors()</code> finally allow <code>alpha</code> to be specified.</li>
<li><code>monthplot()</code> gains parameters to control the look of the reference lines. (Suggestion of Ian McLeod.)</li>
<li>Added support for new <code>%~%</code> relation (“is distributed as”) in plotmath.</li>
<li><code>domain = NA</code> is accepted by <code>gettext()</code> and <code>ngettext()</code>, analogously to <code>stop()</code> etc.</li>
<li><code>termplot()</code> gains a new argument <code>plot = FALSE</code> which returns information to allow the plots to be modified for use as part of other plots, but does not plot them. (Contributed by Terry Therneau, <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15076">PR#15076</a>.)</li>
<li><code>quartz.save()</code>, formerly an undocumented part of <code>R.app</code>, is now available to copy a device to a <code>quartz()</code> device. <code>dev.copy2pdf()</code>optionally does this for PDF output: <code>quartz.save()</code> defaults to PNG.</li>
<li>The default method of <code>pairs()</code> now allows <code>text.panel = NULL</code> and the use of <code>&lt;foo&gt;.panel = NULL</code> is now documented.</li>
<li><code>setRefClass()</code> and <code>getRefClass()</code> now return class generator functions, similar to <code>setClass()</code>, but still with the reference fields and methods as before (suggestion of Romain Francois).</li>
<li>New functions <code>bitwNot()</code>, <code>bitwAnd()</code>, <code>bitwOr()</code> and <code>bitwXor()</code>, using the internal interfaces previously used for classes<code>"octmode"</code> and <code>"hexmode"</code>.Also <code>bitwShiftL()</code> and <code>bitwShiftR()</code> for shifting bits in elements of integer vectors.</li>
<li>New option <code>"deparse.cutoff"</code> to control the deparsing of language objects such as calls and formulae when printing. (Suggested by a comment of Sarah Goslee.)</li>
<li><code>colors()</code> gains an argument <code>distinct</code>.</li>
<li>New <code>demo(colors)</code> and <code>demo(hclColors)</code>, with utility functions.</li>
<li><code>list.files()</code> (aka <code>dir()</code>) gains a new optional argument <code>no..</code> which allows to exclude <code>"."</code> and <code>".."</code> from listings.</li>
<li>Multiple time series are also of class <code>"matrix"</code>; consequently, <code>head()</code>, e.g., is more useful.</li>
<li><code>encodeString()</code> preserves UTF-8 marked encodings. Thus if factor levels are marked as UTF-8 an attempt is made to print them in UTF-8 in <code>RGui</code> on Windows.</li>
<li><code>readLines()</code> and <code>scan()</code> (and hence <code>read.table()</code>) in a UTF-8 locale now discard a UTF-8 byte-order-mark (BOM). Such BOMs are allowed but not recommended by the Unicode Standard: however Microsoft applications can produce them and so they are sometimes found on websites.The encoding name <code>"UTF-8-BOM"</code> for a connection will ensure that a UTF-8 BOM is discarded.</li>
<li><code>mapply(FUN, a1, ..)</code> now also works when <code>a1</code> (or a further such argument) needs a <code>length()</code> method (which the documented arguments never do). (Requested by Hervé Pagès; with a patch.)</li>
<li><code>.onDetach()</code> is supported as an alternative to <code>.Last.lib</code>. Unlike <code>.Last.lib</code>, this does not need to be exported from the package&#8217;s namespace.</li>
<li>The <code>srcfile</code> argument to <code>parse()</code> may now be a character string, to be used in error messages.</li>
<li>The <code>format()</code> method for <code>ftable</code> objects gains a <code>method</code> argument, propagated to <code>write.ftable()</code> and <code>print()</code>, allowing more compact output, notably for LaTeX formatting, thanks to Marius Hofert.</li>
<li>The <code>utils::process.events()</code> function has been added to trigger immediate event handling.</li>
<li><code>Sys.which()</code> now returns <code>NA</code> (not <code>""</code>) for <code>NA</code> inputs (related to <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15147">PR#15147</a>).</li>
<li>The <code>print()</code> method for class <code>"htest"</code> gives fewer trailing spaces (wish of <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15124">PR#15124</a>).Also print output from <code>HoltWinters()</code>, <code>nls()</code> and others.</li>
<li><code>loadNamespace()</code> allows a version specification to be given, and this is used to check version specifications given in the Importsfield when a namespace is loaded.</li>
<li><code>setClass()</code> has a new argument, <code>slots</code>, clearer and less ambiguous than <code>representation</code>. It is recommended for future code, but should be back-compatible. At the same time, the allowed slot specification is slightly more general. See the documentation for details.</li>
<li><code>mget()</code> now has a default for <code>envir</code> (the frame from which it is called), for consistency with <code>get()</code> and <code>assign()</code>.</li>
<li><code>close()</code> now returns an integer status where available, invisibly. (Wish of <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15088">PR#15088</a>.)</li>
<li>The internal method of <code>tar()</code> can now store paths too long for the ustar format, using the (widely supported) GNU extension. It can also store long link names, but these are much less widely supported. There is support for larger files, up to the ustar limit of 8GB.</li>
<li>Local reference classes have been added to package methods. These are a technique for avoiding unneeded copying of large components of objects while retaining standard <b>R</b> functional behavior. See <code>?LocalReferenceClasses</code>.</li>
<li><code>untar()</code> has a new argument <code>restore_times</code> which if false (not the default) discards the times in the tarball. This is useful if they are incorrect (some tarballs submitted to <acronym>CRAN</acronym> have times in a local timezone or many years in the past even though the standard required them to be in UTC).</li>
<li><code>replayplot()</code> cannot (and will not attempt to) replay plots recorded under <b>R</b> &lt; 3.0.0. It may crash the <b>R</b> session if an attempt is made to replay plots created in a different build of <b>R</b> &gt;= 3.0.0.</li>
<li>Palette changes get recorded on the display list, so replaying plots (including when resizing screen devices and using <code>dev.copy()</code>) will work better when the palette is changed during a plot.</li>
<li><code>chol(pivot = TRUE)</code> now defaults to LAPACK, not LINPACK.</li>
<li>The <code>parse()</code> function has a new parameter <code>keep.source</code>, which defaults to <code>options("keep.source")</code>.</li>
<li>Profiling via <code>Rprof()</code> now optionally records information at the statement level, not just the function level.</li>
<li>The <code>Rprof()</code> function now quotes function names in in its output file on Windows, to be consistent with the quoting in Unix.</li>
<li>Profiling via <code>Rprof()</code> now optionally records information about time spent in GC.</li>
<li>The HTML help page for a package now displays non-vignette documentation files in a more accessible format.</li>
<li>To support <code>options(stringsAsFactors = FALSE)</code>, <code>model.frame()</code>, <code>model.matrix()</code> and <code>replications()</code> now automatically convert character vectors to factors without a warning.</li>
<li>The <code>print</code> method for objects of class <code>"table"</code> now detects tables with 0-extents and prints the results as, e.g., &lt; table of extent 0 x 1 x 2 &gt;. (Wish of <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15198">PR#15198</a>.)</li>
<li>Deparsing involving calls to anonymous functions and has been made closer to reversible by the addition of extra parentheses.</li>
<li>The function <code>utils::packageName()</code> has been added as a lightweight version of <code>methods::getPackageName()</code>.</li>
<li><code>find.package(lib.loc = NULL)</code> now treats loaded namespaces preferentially in the same way as attached packages have been for a long time.</li>
<li>In Windows, the Change Directory dialog now defaults to the current working directory, rather than to the last directory chosen in that dialog.</li>
<li><code>available.packages()</code> gains a <code>"license/restricts_use"</code> filter which retains only packages for which installation can proceed solely based on packages which are guaranteed not to restrict use.</li>
<li>New <code>check_packages_in_dir()</code> function in package tools for conveniently checking source packages along with their reverse dependencies.</li>
<li>R&#8217;s completion mechanism has been improved to handle help requests (starting with a question mark). In particular, help prefixes are now supported, as well as quoted help topics. To support this, completion inside quotes are now handled by R by default on all platforms.</li>
<li>The memory manager now allows the strategy used to balance garbage collection and memory growth to be controlled by setting the environment variable R_GC_MEM_GROW. See <code>?Memory</code> for more details.</li>
<li>(‘For experts only’, as the introductory manual says.) The use of environment variables R_NSIZE and R_VSIZE to control the initial (= minimum) garbade collection trigger for number of cons cels and size of heap has been restored: they can be overridden by the command-line options <code>--min-nsize</code> and <code>--min-vsize</code>; see <code>?Memory</code>.</li>
<li>On Windows, the device name for bitmap devices as reported by <code>.Device</code> and <code>.Devices</code> no longer includes the file name. This is for consistency with other platforms and was requested by the <a href="http://cran.r-project.org/package=lattice">lattice</a> maintainer.<code>win.metafile()</code> still uses the file name: the exact form is used by package <a href="http://cran.r-project.org/package=tkrplot">tkrplot</a>.</li>
<li><code>set.seed(NULL)</code> re-initializes <code>.Random.seed</code> as done at the beginning of the session if not already set. (Suggestion of Bill Dunlap.)</li>
<li>The <code>breaks</code> argument in <code>hist.default()</code> can now be a function that returns the breakpoints to be used (previously it could only return the suggested number of breakpoints).</li>
<li>File ‘share/licenses/licenses.db’ has some clarifications, especially as to which variants of ‘BSD’ and ‘MIT’ is intended and how to apply them to packages. The problematic licence ‘Artistic-1.0’ has been removed.</li>
</ul>
<h4>LONG VECTORS</h4>
<p>This section applies only to 64-bit platforms.</p>
<ul>
<li>There is support for vectors longer than <i>2^31 &#8211; 1</i> elements. This applies to raw, logical, integer, double, complex and character vectors, as well as lists. (Elements of character vectors remain limited to <i>2^31 &#8211; 1</i> bytes.)</li>
<li>Most operations which can sensibly be done with long vectors work: others may return the error ‘long vectors not supported yet’. Most of these are because they explicitly work with integer indices (e.g. <code>anyDuplicated()</code> and <code>match()</code>) or because other limits (e.g. of character strings or matrix dimensions) would be exceeded or the operations would be extremely slow.</li>
<li><code>length()</code> returns a double for long vectors, and lengths can be set to <i>2^31</i> or more by the replacement function with a double value.</li>
<li>Most aspects of indexing are available. Generally double-valued indices can be used to access elements beyond <i>2^31 &#8211; 1</i>.</li>
<li>There is some support for matrices and arrays with each dimension less than <i>2^31</i> but total number of elements more than that. Only some aspects of matrix algebra work for such matrices, often taking a very long time. In other cases the underlying Fortran code has an unstated restriction (as was found for complex <code>svd()</code>).</li>
<li><code>dist()</code> can produce dissimilarity objects for more than 65536 rows (but for example <code>hclust()</code> cannot process such objects).</li>
<li><code>serialize()</code> to a raw vector is unlimited in size (except by resources).</li>
<li>The C-level function <code>R_alloc</code> can now allocate <i>2^35</i> or more bytes.</li>
<li><code>agrep()</code> and <code>grep()</code> will return double vectors of indices for long vector inputs.</li>
<li>Many calls to <code>.C()</code> have been replaced by <code>.Call()</code> to allow long vectors to be supported (now or in the future). Regrettably several packages had copied the non-API <code>.C()</code> calls and so failed.</li>
<li><code>.C()</code> and <code>.Fortran()</code> do not accept long vector inputs. This is a precaution as it is very unlikely that existing code will have been written to handle long vectors (and the <b>R</b> wrappers often assume that <code>length(x)</code> is an integer).</li>
<li>Most of the methods for <code>sort()</code> work for long vectors.<code>rank()</code>, <code>sort.list()</code> and <code>order()</code> support long vectors (slowly except for radix sorting).</li>
<li><code>sample()</code> can do uniform sampling from a long vector.</li>
</ul>
<h4>PERFORMANCE IMPROVEMENTS</h4>
<ul>
<li>More use has been made of <b>R</b> objects representing registered entry points, which is more efficient as the address is provided by the loader once only when the package is loaded.This has been done for packages <code>base</code>, <code>methods</code>, <code>splines</code> and <code>tcltk</code>: it was already in place for the other standard packages.
<p>Since these entry points are always accessed by the <b>R</b> entry points they do not need to be in the load table which can be substantially smaller and hence searched faster. This does mean that <code>.C</code> / <code>.Fortran</code> / <code>.Call</code> calls copied from earlier versions of <b>R</b> may no longer work – but they were never part of the API.</li>
<li>Many <code>.Call()</code> calls in package base have been migrated to <code>.Internal()</code> calls.</li>
<li><code>solve()</code> makes fewer copies, especially when <code>b</code> is a vector rather than a matrix.</li>
<li><code>eigen()</code> makes fewer copies if the input has dimnames.</li>
<li>Most of the linear algebra functions make fewer copies when the input(s) are not double (e.g. integer or logical).</li>
<li>A foreign function call (<code>.C()</code> etc) in a package without a <code>PACKAGE</code> argument will only look in the first DLL specified in the ‘NAMESPACE’ file of the package rather than searching all loaded DLLs. A few packages needed <code>PACKAGE</code> arguments added.</li>
<li>The <code>@&lt;-</code> operator is now implemented as a primitive, which should reduce some copying of objects when used. Note that the operator object must now be in package base: do not try to import it explicitly from package methods.</li>
</ul>
<h4>PACKAGE INSTALLATION</h4>
<ul>
<li>The transitional support for installing packages without namespaces (required since <b>R</b> 2.14.0) has been removed. <code>R CMD build</code> will still add a namespace, but a <code>.First.lib()</code> function will need to be converted.<code>R CMD INSTALL</code> no longer adds a namespace (so installation will fail), and a <code>.First.lib()</code> function in a package will be ignored (with an installation warning for now).
<p>As an exception, packages without a ‘R’ directory and no ‘NAMESPACE’ file can still be installed.</li>
<li>Packages can specify in their ‘DESCRIPTION file’ a line like
<pre>     Biarch: yes</pre>
<p>to be installed on Windows with &#8211;force-biarch.</li>
<li>Package vignettes can now be processed by other engines besides <code>Sweave</code>; see ‘Writing R Extensions’ and the<code>tools::vignetteEngine</code> help topic for details.</li>
<li>The ‘*.R’ tangled source code for vignettes is now included in tarballs when <code>R CMD build</code> is used to produce them. In <b>R</b> 3.0.0, ‘*.R’ files not in the sources will be produced at install time, but eventually this will be dropped.</li>
<li>The package type <code>"mac.binary"</code> now looks in a path in the repository without any Mac subtype (which used to be universal orleopard): it looks in ‘bin/macosx/contrib/3.0’ rather than ‘bin/macosx/leopard/contrib/2.15’). This is the type used for the <acronym>CRAN</acronym>binary distribution for OS X as from <b>R</b> 3.0.0.</li>
<li>File ‘etc/Makeconf’ makes more use of the macros <code>$(CC)</code>, <code>$(CXX)</code>, <code>$(F77)</code> and <code>$(FC)</code>, so the compiler in use can be changed by setting just these (and if necessary the corresponding flags and <code>FLIBS</code>) in file ‘~/.R/Makevars’.This is convenient for those working with binary distributions of <b>R</b>, e.g. on OS X.</li>
</ul>
<h4>UTILITIES</h4>
<ul>
<li><code>R CMD check</code> now gives a warning rather than a note if it finds calls to <code>abort</code>, <code>assert</code> or <code>exit</code> in compiled code, and has been able to find the ‘.o’ file in which the calls occur.Such calls can terminate the <b>R</b> process which loads the package.</li>
<li>The location of the build and check environment files can now be specified by the environment variables R_BUILD_ENVIRON andR_CHECK_ENVIRON, respectively.</li>
<li><code>R CMD Sweave</code> gains a &#8211;compact option to control possibly reducing the size of the PDF file it creates when &#8211;pdf is given.</li>
<li><code>R CMD build</code> now omits Eclipse&#8217;s ‘.metadata’ directories, and <code>R CMD check</code> warns if it finds them.</li>
<li><code>R CMD check</code> now does some checks on functions defined within reference classes, including of <code>.Call()</code> etc calls.</li>
<li><code>R CMD check --as-cran</code> notes assignments to the global environment, calls to <code>data()</code> which load into the global environment, and calls to <code>attach()</code>.</li>
<li><code>R CMD build</code> by default uses the internal method of <code>tar()</code> to prepare the tarball. This is more likely to produce a tarball compatible with <code>R CMD INSTALL</code> and <code>R CMD check</code>: an external <code>tar</code> program, including options, can be specified <em>via</em> the environment variableR_BUILD_TAR.</li>
<li><code>tools::massageExamples()</code> is better protected against packages which re-define base functions such as <code>cat()</code> and <code>get()</code> and so can cause <code>R CMD check</code> to fail when checking examples.</li>
<li><code>R CMD javareconf</code> has been enhanced to be more similar to the code used by <code>configure</code>.There is now a test that a JNI program can be compiled (like <code>configure</code> did) and only working settings are used.
<p>It makes use of custom settings from configuration recorded in ‘etc/javaconf’.</li>
<li>The &#8211;no-vignettes argument of <code>R CMD build</code> has been renamed to the more accurate &#8211;no-build-vignettes: its action has always been to (re)build vignettes and never omitted them.<code>R CMD check</code> accepts &#8211;no-build-vignettes as a preferred synonym for &#8211;no-rebuild-vignettes.</li>
</ul>
<h4>DEPRECATED AND DEFUNCT</h4>
<ul>
<li>The <code>ENCODING</code> argument to <code>.C()</code> is defunct. Use <code>iconv()</code> instead.</li>
<li>The <code>.Internal(eval.with.vis)</code> non-API function has been removed.</li>
<li>Support for the converters for use with <code>.C()</code> has been removed, including the oft misused non-API header ‘R_ext/RConverters.h’.</li>
<li>The previously deprecated uses of <code>array()</code> with a 0-length <code>dim</code> argument and <code>tapply()</code> with a 0-length <code>INDEX</code> list are now errors.</li>
<li>Translation packages are defunct.</li>
<li>Calling <code>rep()</code> or <code>rep.int()</code> on a pairlist or other non-vector object is now an error.</li>
<li>Several non-API entry points have been transferred to packages (e.g. <code>R_zeroin2</code>) or replaced by different non-API entry points (e.g.<code>R_tabulate</code>).</li>
<li>The ‘internal’ graphics device invoked by <code>.Call("R_GD_nullDevice", package = "grDevices")</code> has been removed: use<code>pdf(file = NULL)</code> instead.</li>
<li>The <code>.Fortran()</code> entry point <code>"dqrls"</code> which has not been used by <b>R</b> since version 2.15.1 is no longer available.</li>
<li>Functions <code>traceOn()</code> and <code>traceOff()</code> in package methods are now defunct.</li>
<li>Function <code>CRAN.packages()</code> is finally defunct.</li>
<li>Use of <code>col2rgb(0)</code> is defunct: use <code>par("bg")</code> or <code>NA</code> instead.</li>
<li>The long-defunct functions <code>Rd_parse()</code>, <code>anovalist.lm()</code>, <code>categpry()</code>, <code>clearNames()</code>, <code>gammaCody()</code>, <code>glm.fit.null()</code>,<code>lm.fit.null()</code>, <code>lm.wfit.null()</code>, <code>manglePackageNames()</code>, <code>mauchley.test()</code>, <code>package.contents()</code>, <code>print.coefmat()</code>,<code>reshapeLong()</code>, <code>reshapeWide()</code>, <code>tkclose()</code>, <code>tkcmd()</code>, <code>tkfile.dir()</code>, <code>tkfile.tail()</code>, <code>tkopen()</code>, <code>tkputs()</code>, <code>tkread()</code>,<code>trySilent()</code> and <code>zip.file.extract()</code> have been removed entirely (but are still documented in the help system).</li>
<li>The unused <code>dataPath</code> argument to <code>attachNamespace()</code> has been removed.</li>
<li><code>grid.prompt()</code> has been removed: use <code>devAskNewPage()</code> instead.</li>
<li>The long-deprecated <code>intensities</code> component is no longer returned by <code>hist()</code>.</li>
<li><code>mean()</code> for data frames and <code>sd()</code> for data frames and matrices are defunct.</li>
<li><code>chol(pivot = FALSE, LINPACK = TRUE)</code>, <code>ch2inv(LINPACK = TRUE)</code>, <code>eigen(EISPACK = TRUE)</code>, <code>solve(LINPACK = TRUE)</code> and<code>svd(LINPACK = TRUE)</code> are defunct: LAPACK will be used, with a warning.</li>
<li>The <code>keep.source</code> argument to <code>library()</code> and <code>require()</code> is defunct. This option needs to be set at install time.</li>
<li>Documentation for <code>real()</code>, <code>as.real()</code> and <code>is.real()</code> has been moved to ‘defunct’ and the functions removed.</li>
<li>The <code>maxRasters</code> argument of <code>pdf()</code> (unused since <b>R</b> 2.14.0) has been removed.</li>
<li>The unused <code>fontsmooth</code> argument has been removed from the <code>quartz()</code> device.</li>
<li>All the (non-API) EISPACK entry points in <b>R</b> have been removed.</li>
<li><code>chol(pivot = TRUE, LINPACK = TRUE)</code> is deprecated.</li>
<li>The long-deprecated use of <code>\synopsis</code> in the Usage section of ‘.Rd’ files will be removed in <b>R</b> 3.1.0.</li>
<li><code>.find.package()</code> and <code>.path.package()</code> are deprecated: only the public versions without the dot have ever been in the API.</li>
</ul>
<h4>CODE MIGRATION</h4>
<ul>
<li>The C code underlying base graphics has been migrated to the graphics package (and hence no longer uses <code>.Internal()</code> calls).</li>
<li>Most of the <code>.Internal()</code> calls used in the stats package have been migrated to C code in that package.This means that a number of <code>.Internal()</code> calls which have been used by packages no longer exist, including <code>.Internal(cor)</code><code>.Internal(cov)</code>, <code>.Internal(optimhess)</code> and <code>.Internal(update.formula)</code>.</li>
<li>Some <code>.External()</code> calls to the <code>base</code> package (really to the <b>R</b> executable or shared library) have been moved to more appropriate packages. Packages should not have been using such calls, but some did (mainly those used by <code>integrate()</code>).</li>
</ul>
<h4>PACKAGE parallel</h4>
<ul>
<li>There is a new function <code>mcaffinity()</code> which allows getting or setting the CPU affinity mask for the current <b>R</b> process on systems that supports this (currently only Linux has been tested successfully). It has no effect on systems which do not support process affinity. Users are not expected to use this function directly (with the exception of fixing libraries that break affinity settings like OpenBLAS) – the function is rather intended to support affinity control in high-level parallel functions. In the future, <b>R</b> may supplement lack of affinity control in the OS by its own bookkeeping via <code>mcaffinity()</code> related to processes and threads it spawns.</li>
<li><code>mcparallel()</code> has a new argument <code>mc.affinity</code> which attempts to set the affinity of the child process according to the specification contained therein.</li>
<li>The port used by socket clusters is chosen randomly: this should help to avoid clashes observed when two users of a multi-user machine try to create a cluster at the same time. To reproduce the previous behaviour set environment variable R_PARALLEL_PORTto <code>10187</code>.</li>
</ul>
<h4>C-LEVEL FACILITIES</h4>
<ul>
<li>There has been some minor re-organization of the non-API header files. In particular, ‘Rinternals.h’ no longer includes the non-API header ‘R_exts/PrtUtil.h’, and that no longer includes ‘R_exts/Print.h’.</li>
<li>Passing <code>NULL</code> to <code>.C()</code> is now an error.</li>
<li><code>.C()</code> and <code>.Fortran()</code> now warn if <code>"single"</code> arguments are used with <code>DUP = FALSE</code>, as changes to such arguments are not returned to the caller.</li>
<li>C entry points <code>R_qsort</code> and <code>R_qsort_I</code> now have <code>start</code> and <code>end</code> as <code>size_t</code> to allow them to work with longer vectors on 64-bit platforms. Code using them should be recompiled.</li>
<li>A few recently added C entry points were missing the remapping to <code>Rf_</code>, notably <code>[dpq]nbinom_mu</code>.</li>
<li>Some of the interface pointers formerly available only to <code>R.app</code> are now available to front-ends on all Unix-alikes: one has been added for the interface to <code>View()</code>.</li>
<li><code>PACKAGE = ""</code> is now an error in <code>.C()</code> etc calls: it was always contrary to the documentation.</li>
<li>Entry point <code>rcont2</code> has been migrated to package stats and so is no longer available.</li>
<li><code>R_SVN_REVISION</code> in ‘Rversion.h’ is now an integer (rather than a string) and hence usable as e.g. <code>#if R_SVN_REVISION &lt; 70000</code>.</li>
<li>The entry points <code>rgb2hsv</code> and <code>hsv2rgb</code> have been migrated to package grDevices and so are no longer available.</li>
<li><code>R_GE_version</code> has been increased to <code>10</code> and <code>name2col</code> removed (use <code>R_GE_str2col</code> instead). <b>R</b> internal colour codes are now defined using the typedef <code>rcolor</code>.</li>
<li>The <code>REPROTECT</code> macro now checks that the protect index is valid.</li>
<li>Several non-API entry points no longer used by <b>R</b> have been removed, including the Fortran entry points <code>chol</code>, <code>chol2inv</code>, <code>cg</code>, <code>ch</code> and<code>rg</code>, and the C entry points <code>Brent_fmin</code>, <code>fft_factor</code> and <code>fft_work</code>.</li>
<li>If a <code>.External</code> call is registered with a number of arguments (other than <code>-1</code>), the number of arguments passed is checked for each call (as for other foreign function calls).</li>
<li>It is now possible to write custom connection implementations outside core R using ‘R_ext/Connections.h’. Please note that the implementation of connections is still considered internal and may change in the future (see the above file for details).</li>
</ul>
<h4>INTERNATIONALIZATION</h4>
<ul>
<li>The management of translations has been converted to <b>R</b> code: see <code>?tools::update_pkg_po</code>.</li>
<li>The translations for the <b>R</b> interpreter and <code>RGui.exe</code> are now part of the base package (rather than having sources in directory ‘po’ and being installed to ‘share/locale’). Thus the base package supports three translation domains, <code>R-base</code>, <code>R</code> and <code>RGui</code>.</li>
<li>The compiled translations which ship with <b>R</b> are all installed to the new package translations for easier updating. The first package of that name found on <code>.libPaths()</code> at the start of the <b>R</b> session will be used. (It is possible messages will be used before <code>.libPaths()</code>is set up in which case the default translations will be used: set environment variable R_TRANSLATIONS to point to the location of the intended translations package to use this right from the start.)</li>
<li>The translations form a separate group in the Windows installer, so can be omitted if desired.</li>
<li>The markup for many messages has been changed to make them easier to translate, incorporating suggestions from Łukasz Daniel.</li>
</ul>
<h4>INSTALLATION</h4>
<ul>
<li>There is again support for building without using the C ‘long double’ type. This is required by C99, but system implementations can be slow or flawed. Use <code>configure</code> option &#8211;disable-long-double.</li>
<li><code>make pdf</code> and <code>make install-pdf</code> now make and install the full reference index (including all base and recommended packages).</li>
<li>The &#8216;reference manual&#8217; on the Windows GUI menu and included in the installer is now the full reference index, including all base and recommended packages.</li>
<li>The Windows installer no longer installs a Start Menu link to the static help pages; as most pages are generated dynamically, this led to a lot of broken links.</li>
<li>Any custom settings for Java configuration are recorded in file ‘etc/javaconf’ for subsequent use by <code>R CMD javareconf</code>.</li>
<li>There is now support for <code>makeinfo</code> version 5.0 (which requires a slightly different ‘.texi’ syntax).</li>
<li>The minimum versions for &#8211;use-system-zlib and <code>--use-system-pcre</code> are now tested as 1.2.5 and 8.10 respectively.</li>
<li>On Windows, the stack size is reduced to 16MB on 32-bit systems: misguided users were launching many threads without controlling the stack size.</li>
<li><code>configure</code> no longer looks for file ‘~/.Rconfig’: ‘~/.R/config’ has long been preferred.</li>
</ul>
<h4>BUG FIXES</h4>
<ul>
<li>When <code>R CMD build</code> is run in an encoding other than the one specified in the package&#8217;s ‘DESCRIPTION’ file it tries harder to expand the <code>authors@R</code> field in the specified encoding. (<a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14958">PR#14958</a>)</li>
<li>If <code>R CMD INSTALL</code> is required to expand the <code>authors@R</code> field of the ‘DESCRIPTION’ file, it tries harder to do so in the encoding specified for the package (rather than using ASCII escapes).</li>
<li>Fix in package grid for pushing a viewport into a layout cell, where the layout is within a viewport that has zero physical width OR where the layout has zero total relative width (likewise for height). The layout column widths (or row heights) in this case were being calculated with non-finite values. (Reported by Winston Chang.)</li>
<li><code>solve(A, b)</code> for a vector <code>b</code> gave the answer names from <code>colnames(A)</code> for <code>LINPACK = TRUE</code> but not in the default case.</li>
<li><code>La.svd()</code> accepts logical matrices (as documented, and as <code>svd()</code> did).</li>
<li><code>legend()</code> now accepts negative <code>pch</code> values, in the same way <code>points()</code> long has.</li>
<li>Parse errors when installing files now correctly display the name of the file containing the bad code.</li>
<li>In Windows, tcltk windows were not always properly constructed. (<a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15150">PR#15150</a>)</li>
<li>The internal functions implementing <code>parse()</code>, <code>tools::parseLatex()</code> and <code>tools::parse_Rd()</code> were not reentrant, leading to errors in rare circumstances such as a garbage collection triggering a recursive call.</li>
<li>Field assignments in reference class objects via <code>$&lt;-</code> were not being checked because the magic incantation to turn methods on for that primitive operator had been inadvertently omitted.</li>
<li><code>setHook(hookname, value, action="replace")</code> set the hook to be the value, rather than a list containing the value as documented. (<a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15167">PR#15167</a>)</li>
<li>If a package used a ‘NEWS.Rd’ file, the main HTML package index page did not link to it. (Reported by Dirk Eddelbuettel.)</li>
<li>The primitive implementation of <code>@&lt;-</code> was not checking the class of the replacement. It now does a check, quicker but less general than<code>slot&lt;-</code>. See the help.</li>
<li><code>split(x, f)</code> now recycles classed objects <code>x</code> in the same way as vectors. (Reported by Martin Morgan.)</li>
<li><code>pbeta(.28, 1/2, 2200, lower.tail=FALSE, log.p=TRUE)</code> is no longer <code>-Inf</code>; ditto for corresponding <code>pt()</code> and <code>pf()</code> calls, such as <code>pt(45, df=5000, lower.tail=FALSE, log.p=TRUE)</code>. (<a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15162">PR#15162</a>)</li>
<li>The Windows graphics device would crash <b>R</b> if a user attempted to load the graphics history from a variable that was not a saved history. (<a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15230">PR#15230</a>)</li>
<li>The workspace size for the <code>predict()</code> method for <code>loess()</code> could exceed the maximum integer size. (Reported by Hiroyuki Kawakatsu.)</li>
<li><code>ftable(x, row.vars, col.vars)</code> now also works when the <code>*.vars</code> arguments are (integer or character vectors) of length zero.</li>
<li>Calling <code>cat()</code> on a malformed UTF-8 string could cause the Windows GUI to lock up. (<a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15227">PR#15227</a>)</li>
</ul>
<p><img src="http://cran.r-project.org/bin/windows/html/logo.jpg" alt="R logo" /></p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/04/r-3-0-0-is-released-whats-new-and-how-to-upgrade/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/04/r-3-0-0-is-released-whats-new-and-how-to-upgrade/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Updating R (on Windows) through a menu-bar: installr 0.9 released on CRAN</title>
		<link>http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/</link>
		<comments>http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/#comments</comments>
		<pubDate>Mon, 01 Apr 2013 13:06:25 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[Reproducible Research]]></category>
		<category><![CDATA[devtools]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[installr]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[pandoc]]></category>
		<category><![CDATA[R package]]></category>
		<category><![CDATA[RTools]]></category>
		<category><![CDATA[update R]]></category>
		<category><![CDATA[updater]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60966</guid>
		<description><![CDATA[In preparation for the upcoming release of R 3.0.0, a new release 0.9 of installr is now on CRAN. The package can be installed and loaded using: # installing/loading the package: if&#40;!require&#40;installr&#41;&#41; &#123; install.packages&#40;&#34;installr&#34;&#41;; require&#40;installr&#41;&#125; #load / install+load installr The &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>In preparation for the <a href="https://stat.ethz.ch/pipermail/r-announce/2013/000559.html">upcoming release of R 3.0.0</a>, a new release 0.9 of <a href="https://github.com/talgalili/installr">installr</a> is <a href="http://cran.r-project.org/web/packages/installr/">now on CRAN</a>.</p>
<p>The package can be installed and loaded using:</p>

<div class="wp_codebox"><table><tr id="p6096610"><td class="code" id="p60966code10"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> 
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span></pre></td></tr></table></div>

<p>The new version includes various bug fixes (as can be seen in <a href="http://cran.r-project.org/web/packages/installr/NEWS">the NEWS file</a>) and new functions and features.  The most user visible feature is that from now on, whenever loading installr in the Rgui, it will add a new menu-bar for updating your R version (the menu is removed when the package is <em>detach</em>ed).</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/03/installr_menubar_updateR.png"><img src="http://www.r-statistics.com/wp-content/uploads/2013/03/installr_menubar_updateR.png" alt="installr_menubar_updateR" width="425" height="179" class="aligncenter size-full wp-image-60968" /></a></p>
<p>When choosing to update R, a new GUI based system will guide you step by step through the updating process.  It will first check if a newer version of R is available, if so, it will offer to show the latest NEWS of that release, download and install the new version, and copy/move your packages from the previous library folder, to the one in the new installation.  If you have a global library folder, you can simply stop the updating once your new R is installed, and continue as you would otherwise (in the future, I intend to update the package to also allow it to deal with people using a global library folder).</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/03/installr_updateR_noupdate_needed.png"><img src="http://www.r-statistics.com/wp-content/uploads/2013/03/installr_updateR_noupdate_needed.png" alt="installr_updateR_noupdate_needed" width="392" height="224" class="aligncenter size-full wp-image-60969" /></a></p>
<p>(for using {installr} to update R through R terminal, see my previous post: <a href="http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/">Updating R from R (on Windows) – using the {installr} package</a>)</p>
<p>Another new feature is the &#8220;installr()&#8221; function (which can also be run through the menubar), running it will open a window with a list of software you can download and install using the installr package (From Rtools and RStudio to pandoc and MikTeX).</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/03/installr_installr_function.png"><img src="http://www.r-statistics.com/wp-content/uploads/2013/03/installr_installr_function.png" alt="installr_installr_function" width="362" height="466" class="aligncenter size-full wp-image-60970" /></a></p>
<p>I hope you&#8217;ll enjoy this new release, and as always &#8211; please let me know in the comments (or via e-mail) if you come across any bugs or have suggestions for new features.</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/04/updating-r-on-windows-through-a-menu-bar-installr-0-9-released-on-cran/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Writing a MS-Word document using R (with as little overhead as possible)</title>
		<link>http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/</link>
		<comments>http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/#comments</comments>
		<pubDate>Mon, 25 Mar 2013 02:52:56 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[Reproducible Research]]></category>
		<category><![CDATA[brew]]></category>
		<category><![CDATA[Gergely Daróczi]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Jeffrey Horner]]></category>
		<category><![CDATA[knitr]]></category>
		<category><![CDATA[markdown]]></category>
		<category><![CDATA[pander]]></category>
		<category><![CDATA[rmarkdown]]></category>
		<category><![CDATA[RStudio]]></category>
		<category><![CDATA[sweave]]></category>
		<category><![CDATA[Yihui Xie]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60950</guid>
		<description><![CDATA[The problem: producing a Word (.docx) file of a statistical report created in R, with as little overhead as possible. The solution: combining R+knitr+rmarkdown+pander+pandoc (it is easier than it is spelled). If you get what this post is about, just &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p><strong>The problem</strong>: producing a Word (.docx) file of a statistical report created in R, with as little overhead as possible.<br />
<strong>The solution</strong>: combining R+knitr+rmarkdown+pander+pandoc (it is easier than it is spelled).</p>
<p>If you get what this post is about, just jump to the &#8220;Solution: the workflow&#8221; section.</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/03/rmd_to_docx.png"><img src="http://www.r-statistics.com/wp-content/uploads/2013/03/rmd_to_docx-300x188.png" alt="rmd_to_docx" width="300" height="188" class="aligncenter size-medium wp-image-60963" /></a></p>
<h3>Preface: why is this a problem (/still)</h3>
<p>Before turning to the solution, let&#8217;s address two preliminary questions:</p>
<p><strong>Q: Why is it important to be able to create report in Word from R?</strong></p>
<p><strong>A:</strong> Because many researchers we may work with are used to working with Word for editing their text, tracking changes and merging edits between different authors, and copy-pasting text/tables/images from various sources.<br />
This means that a report produced as a PDF file is less useful for collaborating with less-tech-savvy researchers (copying text or tables from PDF is not fun).  Even exchanging HTML files may appear somewhat awkward to fellow researchers.<br />
<span id="more-60950"></span><br />
<strong>Q: But wasn&#8217;t this problem solved already?</strong></p>
<p><strong>A:</strong> Yes and no.  There have been many attempts at solving the problem in the past several years, but many of them came with an overhead which made the solutions un-friendly (the developers and heavy users of these technologies are asked to not be offended &#8211; this is only my opinion, and you&#8217;re welcome to respond and expand my point of view).<br />
Previous solutions include <a href="http://cran.r-project.org/web/packages/SWordInstaller/index.html">SWord</a> and <a href="http://cran.r-project.org/web/packages/R2wd/index.html">R2wd</a>, both rely on the rcom package (and the statconnDCOM or RDCOMClient servers).  Or using online converters to turn PDF files into Word files.</p>
<p><strong>Q: Any more issues?</strong><br />
<strong>A:</strong> Yes. Another big issue is formatting the output.  If I would like my tables to look nice in the output file, I would often need to start wrapping ALL of my output functions with the some function (taken from packages such as <a href="http://cran.r-project.org/web/packages/xtable/index.html">xtable</a>, <a href="http://cran.r-project.org/web/packages/rms/index.html">rms</a>, <a href="http://cran.r-project.org/web/packages/quantreg/index.html">quantreg</a>, <a href="http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/">stargazer</a>, <a href="https://github.com/rapporter/pander/">pander</a>, and more.</p>
<h3>Sources/links</h3>
<p>The solution I propose here is a combination of using the following R packages: <a href="http://yihui.name/knitr/">knitr</a>, <a href="http://cran.r-project.org/web/packages/markdown/index.html">rmarkdown</a>, <a href="http://cran.r-project.org/web/packages/pander/">pander</a>.  Combined with the external tool <a href="http://johnmacfarlane.net/pandoc/">pandoc </a>(easily installed using <a href="http://cran.r-project.org/web/packages/installr/">the installr package</a>).</p>
<p>Combining these ideas together has been discussed before in various places in the past half year or so, here are just a few:</p>
<ul>
<li><a href="http://quantifyingmemory.blogspot.co.il/2013/02/reproducible-research-with-r-knitr.html">Reproducible research with R, Knitr, Pandoc and Word</a></li>
<li><a href="http://kariert.wordpress.com/2012/05/17/reproducible-research-with-markdown-knitr-and-pandoc/">Reproducible research with markdown, knitr and pandoc</a></li>
<li><a href="http://inundata.org/2012/12/25/formatting-tables-in-markdown/">Formatting tables in markdown</a></li>
<li><a href="http://trinkerrstuff.wordpress.com/2013/02/24/workflow-w-reports-package/">Workflow w/ reports package</a></li>
<li>Other links&#8230; (to be extended based on your comments)</li>
</ul>
<h3>Solution: the workflow</h3>
<p>An overview of the steps:</p>
<ol>
<li>Write text with R code chunks weaved-together (I do it using RStudio, markdown, knitr &#8211; in an .rmd file)</li>
<li>At the beginning of the file &#8211; make sure to replace the &#8220;print&#8221; method with that of the markdown wrapping package (see example bellow)</li>
<li>Compile the doc into .md using knitr</li>
<li>Turn the .md into .docx using pandoc</li>
</ol>
<p>Here is an example rmarkdown code for steps 1 and 2:</p>

<div class="wp_codebox"><table><tr id="p6095016"><td class="code" id="p60950code16"><pre class="rsplus" style="font-family:monospace;">&nbsp;
Doc header <span style="color: #ff0000;">1</span>
<span style="color: #080;">============</span>
```<span style="color: #080;">&#123;</span>r set_knitr_chunk_options<span style="color: #080;">&#125;</span>
opts_chunk$set<span style="color: #080;">&#40;</span>echo<span style="color: #080;">=</span>FALSE,<span style="color: #0000FF; font-weight: bold;">message</span><span style="color: #080;">=</span>FALSE,results <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;asis&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># important for making sure the output will be well formatted.</span>
```
&nbsp;
```<span style="color: #080;">&#123;</span>r load_pander_methods<span style="color: #080;">&#125;</span>
<span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>pander<span style="color: #080;">&#41;</span>
replace.<span style="">print</span>.<span style="">methods</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>PKG_name <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;pander&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
   PKG_methods <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">as.<span style="">character</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">methods</span><span style="color: #080;">&#40;</span>PKG_name<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
   print_methods <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">gsub</span><span style="color: #080;">&#40;</span>PKG_name, <span style="color: #ff0000;">&quot;print&quot;</span>, PKG_methods<span style="color: #080;">&#41;</span>
   <span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">seq_along</span><span style="color: #080;">&#40;</span>PKG_methods<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
      f <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">eval</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">parse</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">text</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span>PKG_name,<span style="color: #ff0000;">&quot;:::&quot;</span>, PKG_methods<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span>, sep <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># the new function to use for print</span>
      <span style="color: #0000FF; font-weight: bold;">assign</span><span style="color: #080;">&#40;</span>print_methods<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span>, f, <span style="color: #ff0000;">&quot;.GlobalEnv&quot;</span><span style="color: #080;">&#41;</span>
   <span style="color: #080;">&#125;</span>   
<span style="color: #080;">&#125;</span>
replace.<span style="">print</span>.<span style="">methods</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
<span style="color: #228B22;">## The following might work with some tweaks:</span>
<span style="color: #228B22;">## print &lt;- function (x, ...) UseMethod(&quot;pander&quot;)</span>
```
Some <span style="color: #0000FF; font-weight: bold;">text</span> explaining the analysis we are doing
```<span style="color: #080;">&#123;</span>r<span style="color: #080;">&#125;</span>
<span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">cars</span><span style="color: #080;">&#41;</span><span style="color: #228B22;"># a summary table</span>
fit <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">lm</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">dist</span>~speed, <span style="color: #0000FF; font-weight: bold;">data</span> <span style="color: #080;">=</span> <span style="color: #CC9900; font-weight: bold;">cars</span><span style="color: #080;">&#41;</span>
fit
<span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">cars</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># a plot</span>
```</pre></td></tr></table></div>

<p>The above code can be saved into an .rmd file, for example: example.rmd<br />
This file can now be compiled using knitr:</p>

<div class="wp_codebox"><table><tr id="p6095017"><td class="code" id="p60950code17"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span>knitr<span style="color: #080;">&#41;</span>
knit2html<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;example.rmd&quot;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>This will produce an example.md file, which can be compiled into a Word file using pandoc.<br />
If you don&#8217;t yet have pandoc, and are running a Windows OS, you can quickly <a href="http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/">install pandoc</a> by running the following code in R:</p>

<div class="wp_codebox"><table><tr id="p6095018"><td class="code" id="p60950code18"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> <span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr </span>
<span style="color: #228B22;"># Installing pandoc</span>
install.<span style="">pandoc</span><span style="color: #080;">&#40;</span>use_regex <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Once pandoc is installed, simply run:</p>

<div class="wp_codebox"><table><tr id="p6095019"><td class="code" id="p60950code19"><pre class="rsplus" style="font-family:monospace;">FILE <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">&quot;example&quot;</span>
<span style="color: #0000FF; font-weight: bold;">system</span><span style="color: #080;">&#40;</span>paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;pandoc -o &quot;</span>, FILE, <span style="color: #ff0000;">&quot;.docx &quot;</span>, FILE, <span style="color: #ff0000;">&quot;.md&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>And your .docx file is ready!</p>
<h3>Possible expansions and caveats</h3>
<p>The first caveat of this method is that it relies on markdown and pander, which is (by definition) more limited than using something like LaTeX.  For that purpose, one can decide to work with LaTeX based solutions.  Here is an example of how to do it with several existing packages (this code bellow is not very debugged &#8211; so more careful attention should be given to using it &#8211; I welcome comments and suggestions):</p>

<div class="wp_codebox"><table><tr id="p6095020"><td class="code" id="p60950code20"><pre class="rsplus" style="font-family:monospace;">&nbsp;
```<span style="color: #080;">&#123;</span>r load_pander_methods<span style="color: #080;">&#125;</span>
replace.<span style="">print</span>.<span style="">methods</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>PKG_name <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;pander&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
   PKG_methods <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">as.<span style="">character</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">methods</span><span style="color: #080;">&#40;</span>PKG_name<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
   print_methods <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">gsub</span><span style="color: #080;">&#40;</span>PKG_name, <span style="color: #ff0000;">&quot;print&quot;</span>, PKG_methods<span style="color: #080;">&#41;</span>
   <span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">seq_along</span><span style="color: #080;">&#40;</span>PKG_methods<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
      f <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">eval</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">parse</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">text</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">paste</span><span style="color: #080;">&#40;</span>PKG_name,<span style="color: #ff0000;">&quot;:::&quot;</span>, PKG_methods<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span>, sep <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># the new function to use for print</span>
      <span style="color: #0000FF; font-weight: bold;">assign</span><span style="color: #080;">&#40;</span>print_methods<span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span>, f, <span style="color: #ff0000;">&quot;.GlobalEnv&quot;</span><span style="color: #080;">&#41;</span>
   <span style="color: #080;">&#125;</span>   
<span style="color: #080;">&#125;</span>
<span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>xtable<span style="color: #080;">&#41;</span>
replace.<span style="">print</span>.<span style="">methods</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;xtable&quot;</span><span style="color: #080;">&#41;</span>
```</pre></td></tr></table></div>

<p>Similar solutions can probably be found for HTML documents also. (credit: The above code is based on the help of Ramnath to <a href="http://stackoverflow.com/questions/15599948/replacing-the-print-function-in-knitr-chunk-evaluation/">my question on SO</a>)</p>
<p>The second caveat is that the above solution (at least the part that makes sure we can use the R code as is, without wrapping it with things like &#8220;pander(summary(cars))&#8221;), is basically a dirty hack.  It is a hack in the sense that it overrides basic R commands (which is quite ugly really).  This issue is being thought about and discussed for over a month now in the <a href="https://github.com/yihui/knitr/issues/484">knitr github page</a>, I hope a better solution will come out of it.</p>
<p>The third issue is that if you use a function for which there is an issue with the method, it might cause problems in compiling the code (for example, pander still needs a pander.summary.lm method&#8230;).</p>
<p><strong>To conclude</strong>: Thanks to the amazing work by Yihui on knitr, by the people at RStudio, by Jeffrey Horner on markdown, Gergely Daróczi for pander, and many others &#8211; it is now easier than ever to quickly create a docx report based on analysis performed using R.  It seems that 2012 was a great year for reproducible research, I&#8217;m looking forward to 2013&#8230;</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
		<item>
		<title>Updating R from R (on Windows) &#8211; using the {installr} package</title>
		<link>http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/</link>
		<comments>http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 09:37:38 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[Reproducible Research]]></category>
		<category><![CDATA[check for update]]></category>
		<category><![CDATA[installr]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60932</guid>
		<description><![CDATA[Upgrading R on Windows is not easy. While the R FAQ offer guidelines, some users may prefer to simply run a command in order to upgrade their R to the latest version. That is what the new {installr} package is &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>Upgrading R on Windows is not easy.  While the <a href="http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f">R FAQ offer guidelines</a>, some users may prefer to simply run a command in order to upgrade their R to the latest version.  That is what the <em>new </em><a href="http://cran.r-project.org/web/packages/installr/">{installr}</a> package is all about.</p>
<p>The {<a href="http://cran.r-project.org/web/packages/installr/">installr</a>} package offers a set of R functions for the installation and updating of software (currently, only on Windows OS), with a special focus on R itself.  To update R, you can simply run the following code:</p>

<div class="wp_codebox"><table><tr id="p6093226"><td class="code" id="p60932code26"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> 
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
&nbsp;
<span style="color: #228B22;"># using the package:</span>
updateR<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># this will start the updating process of your R installation.  It will check for newer versions, and if one is available, will guide you through the decisions you'd need to make.</span></pre></td></tr></table></div>

<p>Running this function will perform the following steps:</p>
<ul>
<li>
<p> <strong>Check what is the latest R version</strong>.  If the current installed R version is up-to-date, the function ends (and returns FALSE) </p>
</li>
<li>
<p> If a newer version of R is available, you will be asked if to <strong>review the NEWS</strong> of the latest R version &#8211; in order to decide if to install the<br />
newest R or not. </p>
</li>
<li>
<p> If you wish it &#8211; the function will <strong>download and install</strong> the latest R version. (you will need to press the &quot;next&quot; buttons on your own) </p>
</li>
<li>
<p> Once the installation is done, you should press &quot;any-key&quot;, and the function will proceed with <strong>copying all of your packages</strong> from your old (well, current) R installation, into your newer R installation. </p>
</li>
<li>
<p> You can then <strong>erase </strong>all of the <strong>packages </strong>in your <strong>old R </strong>installation. </p>
</li>
<li>
<p> After your packages are moved (and the old ones possibly erased), you will get the option to <strong>update </strong>all of your <strong>packages </strong>in the new version of R. </p>
</li>
<li>
<p> Lastely &#8211; you can open the new Rgui and close the current session of your old R. (This is a bit buggy in version 0.8, but has been fixed in version 0.8.1)</p>
</li>
</ul>
<p>If you know you wish to upgrade R, and you want the packages moved (not copied, MOVED), you can simply run:</p>

<div class="wp_codebox"><table><tr id="p6093227"><td class="code" id="p60932code27"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> <span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
&nbsp;
updateR<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">T</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># install, move, update.package, quit R.</span></pre></td></tr></table></div>

<p>Since the various steps are broken into individual functions, you can also pick and choose what to run using the relevant function:</p>

<div class="wp_codebox"><table><tr id="p6093228"><td class="code" id="p60932code28"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> <span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
&nbsp;
<span style="color: #228B22;"># step by step functions:</span>
check.<span style="">for</span>.<span style="">updates</span>.<span style="">R</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># tells you if there is a new version of R or not.</span>
install.<span style="">R</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># download and run the latest R installer</span>
copy.<span style="">packages</span>.<span style="">between</span>.<span style="">libraries</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># copy your packages to the newest R installation from the one version before it (if ask=T, it will ask you between which two versions to perform the copying)</span></pre></td></tr></table></div>

<p>If you like using <a href="http://www.r-statistics.com/2010/04/changing-your-r-upgrading-strategy-and-the-r-code-to-do-it-on-windows/">the global library system</a>, you can run the following in the old R:</p>

<div class="wp_codebox"><table><tr id="p6093229"><td class="code" id="p60932code29"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> <span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
&nbsp;
updateR<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">T</span>, <span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">F</span>, <span style="color: #0000FF; font-weight: bold;">T</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># only install R (if there is a newer version), and quits it.</span></pre></td></tr></table></div>

<p>And then run the following in the new version of R:</p>

<div class="wp_codebox"><table><tr id="p6093230"><td class="code" id="p60932code30"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">source</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;http://www.r-statistics.com/wp-content/uploads/2010/04/upgrading-R-on-windows.r.txt&quot;</span><span style="color: #080;">&#41;</span>
New.<span style="">R</span>.<span style="">RunMe</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>The {<a href="http://cran.r-project.org/web/packages/installr/">installr</a>} package also offers functions for installing various other software on Windows.  These functions include: install.pandoc (which was <a href="http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/">mentioned on this blog</a> recently), install.git, install.Rtools, install.MikTeX, install.RStudio, and a general install.URL and install.packages.zip functions.  You can see these further explained in <a href="http://cran.r-project.org/web/packages/installr/installr.pdf">the package&#8217;s Reference manual</a>.</p>
<h3>Feature requests, bug reports &#8211; and your help in improving the package</h3>
<p>You can see the latest version of <a href="https://github.com/talgalili/installr/">installr on github</a>, where you can also <a href="https://github.com/talgalili/installr/issues">submit bug reports</a> (you may also just leave a comment in this post). Since this is my first R package, I might have (e.g: probably have) missed something here or there.  So any comment on how to improve my code/documentation/R-fu, will be most welcomed (here or on github).</p>
<p>If this type of coding is fun/easy for you, you can help me improve <a href="https://github.com/talgalili/installr/">this package on github</a>. Cool new features I think may be added (by me or others) are:</p>
<ul>
<li>Add an uninstall.R function &#8211; to remove the old R version.</li>
<li>Add more support for upgrading R for people who uses <a href="http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/">a global library</a> for their packages.</li>
<li>Add support for Linux and Mac!  This one I am less likely to do on my own &#8211; and would love to see someone else extend my code to other operation systems.</li>
<li>GUI &#8211; add a menu based option for running updateR.  Something like help->&#8221;check for updates&#8221; would be great.  (p.s: this idea came from Yihui Xie)</li>
<li>add even more install.software functions.  If you have functions for which you&#8217;d like to be able to easily install them &#8211; just let me know and it could be included in future releases.</li>
</ul>
<h3>Thanks</h3>
<p>Final note, I would like to thank the many people who have developed WONDERFUL tools for making R package development possible (and even somewhat fast), on Windows.  These include Prof. Brian Ripley and Duncan Murdoch for <a href="http://cran.r-project.org/bin/windows/Rtools/">Rtools</a>, also <a href="http://www.statistik.tu-dortmund.de/ligges.html">Uwe Ligges</a> for his work on CRAN, <a href="http://had.co.nz/">Hadley Wickham</a> for <a href="https://github.com/hadley/devtools">devtools</a> (in general, and for its <a href="https://github.com/hadley/devtools/wiki/Package-basics">documentation</a>), <a href="http://yihui.name/en/">Yihui Xie</a> for <a href="https://github.com/yihui/roxygen2">roxygen2</a>, <a href="http://www.rstudio.com/about/">JJ and others</a> in the RStudio team for <a href="http://www.rstudio.com/">RStudio</a>, the people behind git and github, and more.  There are probably more things I can thank these people for, and many more people I should thank, but I can&#8217;t figure who you are probably (feel free to e-mail me, I appreciate you work even if it is not clear to me your are behind it).</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Installing Pandoc from R (on Windows) – using the {installr} package</title>
		<link>http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/</link>
		<comments>http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/#comments</comments>
		<pubDate>Wed, 27 Feb 2013 13:19:01 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[Reproducible Research]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[pandoc]]></category>
		<category><![CDATA[pandox]]></category>
		<category><![CDATA[upgrading]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60914</guid>
		<description><![CDATA[The R blogger Rolf Fredheim has recently wrote a great piece called &#8220;Reproducible research with R, Knitr, Pandoc and Word&#8220;, where he advocates for Pandoc as an essential part of reproducible research workflow in R, in helping to turn documents &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>The <a href="http://www.r-bloggers.com/reproducible-research-with-r-knitr-pandoc-and-word/">R blogger</a> Rolf Fredheim has recently wrote a great piece called &#8220;<a href="http://quantifyingmemory.blogspot.co.il/2013/02/reproducible-research-with-r-knitr.html">Reproducible research with R, Knitr, Pandoc and Word</a>&#8220;, where he advocates for <a href="http://johnmacfarlane.net/pandoc/">Pandoc</a> as an essential part of reproducible research workflow in R, in helping to turn documents which are <a href="http://yihui.name/knitr/">knitted </a>in R into high quality Word for exchanging with our colleagues.  It is a great post, with many useful bits of code, and I wanted to supplement it with one missing function: &#8220;<strong>install.pandoc</strong>&#8220;.  </p>
<p><strong>Update</strong>: the <em>install.pandoc</em> function is now part of <a href="http://cran.r-project.org/web/packages/installr/">the {installr} package</a>.</p>
<p><span id="more-60914"></span></p>
<p>The <em>install.pandoc()</em> function, as the name implies, will recognize the latest version of pandoc, download its installer to your computer, and run it. Making it even simpler for you to experiment with adding pandoc into your workflow.</p>
<p>Here is how to use it:</p>

<div class="wp_codebox"><table><tr id="p6091432"><td class="code" id="p60914code32"><pre class="rsplus" style="font-family:monospace;">&nbsp;
<span style="color: #228B22;"># installing/loading the package:</span>
<span style="color: #0000FF; font-weight: bold;">if</span><span style="color: #080;">&#40;</span><span style="color: #080;">!</span><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span> <span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;installr&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">;</span> <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>installr<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span> <span style="color: #228B22;">#load / install+load installr</span>
&nbsp;
<span style="color: #228B22;"># Installing pandoc</span>
install.<span style="">pandoc</span><span style="color: #080;">&#40;</span>use_regex <span style="color: #080;">=</span> FALSE<span style="color: #080;">&#41;</span>  <span style="color: #228B22;"># The use of use_regex here is due to a change in pandoc download page.  This parameter will not be needed in installr versions after 0.9</span></pre></td></tr></table></div>

<p><em>Note: the code in this function is based on <a href="http://sitemap.snowl.net/">GERGELY DARÓCZI&#8217;s</a> coding in his answer on <a href="http://stackoverflow.com/questions/15071957/is-it-possible-to-install-pandoc-on-windows-using-an-r-command">the Q&#038;A forum StackOverflow</a>, and also G. Grothendieck for the non-XML addition to the function. I thank them both!<br />
</em></p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/02/pandoc_diagram.png"><img src="http://www.r-statistics.com/wp-content/uploads/2013/02/pandoc_diagram-300x291.png" alt="pandoc_diagram" width="300" height="291" class="aligncenter size-medium wp-image-60920" /></a></p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/02/installing-pandoc-from-r-on-windows/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>{stargazer} package for beautiful LaTeX tables from R statistical models output</title>
		<link>http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/</link>
		<comments>http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/#comments</comments>
		<pubDate>Mon, 14 Jan 2013 08:11:11 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Reproducible Research]]></category>
		<category><![CDATA[knitr]]></category>
		<category><![CDATA[LaTex]]></category>
		<category><![CDATA[Marek Hlavac]]></category>
		<category><![CDATA[sweave]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60897</guid>
		<description><![CDATA[stargazer is a new R package that creates LaTeX code for well-formatted regression tables, with multiple models side-by-side, as well as for summary statistics tables. It can also output the content of data frames directly into LaTeX. Compared to available &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p><b><a href="http://cran.r-project.org/web/packages/stargazer/index.html">stargazer</a></b> is a new R package that creates LaTeX code for well-formatted regression tables, with multiple models side-by-side, as well as for summary statistics tables. It can also output the content of data frames directly into LaTeX. Compared to available alternatives, <b>stargazer</b> excels in three regards:  its ease of use, the large number of models it supports, and its beautiful aesthetics.</p>
<h3>Ease of use</h3>
<p><b>stargazer </b>was designed with the user’s comfort in mind. The learning curve is very mild and all arguments are very intuitive, so that even a beginning user of R or LaTeX can quickly become familiar with the package’s many capabilities. The package is intelligent, and tries to minimize the amount of effort the user has to put into adjusting argument values. If <b>stargazer</b> is given a set of regression model objects, for instance, the package will create a side-by-side regression table. By contrast, if the user feeds it a data frame, <b>stargazer</b> will know that the user is most likely looking for a summary statistics table or – if the <b>summary</b> argument is set to false – wants to output the content of the data frame.</p>
<p>A quick reproducible example shows just how easy <b>stargazer</b> is to use. You can install <b>stargazer</b> from CRAN in the usual way:</p>

<div class="wp_codebox"><table><tr id="p6089737"><td class="code" id="p60897code37"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;stargazer&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span>stargazer<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p><span id="more-60897"></span></p>
<p>To create a summary statistics table from the <b>‘attitude’</b> data frame (which should be available with your default installation of R), simply run the following:</p>

<div class="wp_codebox"><table><tr id="p6089738"><td class="code" id="p60897code38"><pre class="rsplus" style="font-family:monospace;">stargazer<span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">attitude</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_summ_stat.jpg"><img src="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_summ_stat.jpg" alt="stargazer_summ_stat" width="561" height="276" class="aligncenter size-full wp-image-60901" /></a></p>
<p>To output the contents of the first four rows of same data frame, specify the part of the data frame you would like to see, and set the <b>summary</b> option to FALSE:</p>

<div class="wp_codebox"><table><tr id="p6089739"><td class="code" id="p60897code39"><pre class="rsplus" style="font-family:monospace;">stargazer<span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">attitude</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">4</span>,<span style="color: #080;">&#93;</span>, <span style="color: #0000FF; font-weight: bold;">summary</span><span style="color: #080;">=</span>FALSE<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_data_frame.jpg"><img src="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_data_frame-300x78.jpg" alt="stargazer_data_frame" width="300" height="78" class="aligncenter size-medium wp-image-60899" /></a></p>
<p>Now, let us try to create a simple regression table with three side-by-side models – two Ordinary Least Squares (OLS) and one probit regression model – using the <b>lm()</b> and <b>glm()</b> functions. We can set the <b>align</b> argument to TRUE, so that coefficients in each column are aligned along the decimal point:</p>

<div class="wp_codebox"><table><tr id="p6089740"><td class="code" id="p60897code40"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;">## 2 OLS models</span>
linear.1 <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">lm</span><span style="color: #080;">&#40;</span>rating ~ complaints <span style="color: #080;">+</span> privileges <span style="color: #080;">+</span> learning <span style="color: #080;">+</span> raises <span style="color: #080;">+</span> critical, <span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span><span style="color: #CC9900; font-weight: bold;">attitude</span><span style="color: #080;">&#41;</span>
linear.2 <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">lm</span><span style="color: #080;">&#40;</span>rating ~ complaints <span style="color: #080;">+</span> privileges <span style="color: #080;">+</span> learning, <span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span><span style="color: #CC9900; font-weight: bold;">attitude</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">## create an indicator dependent variable, and run a probit model</span>
&nbsp;
<span style="color: #CC9900; font-weight: bold;">attitude</span>$high.<span style="">rating</span> <span style="color: #080;">&lt;-</span> <span style="color: #080;">&#40;</span><span style="color: #CC9900; font-weight: bold;">attitude</span>$rating <span style="color: #080;">&gt;</span> <span style="color: #ff0000;">70</span><span style="color: #080;">&#41;</span>
probit.<span style="">model</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">glm</span><span style="color: #080;">&#40;</span>high.<span style="">rating</span> ~ learning <span style="color: #080;">+</span> critical <span style="color: #080;">+</span> advance, <span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span><span style="color: #CC9900; font-weight: bold;">attitude</span>, <span style="color: #0000FF; font-weight: bold;">family</span> <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">binomial</span><span style="color: #080;">&#40;</span>link <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;probit&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
stargazer<span style="color: #080;">&#40;</span>linear.1, linear.2, probit.<span style="">model</span>, <span style="color: #0000FF; font-weight: bold;">title</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;Regression Results&quot;</span>, align<span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_regression.jpg"><img src="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_regression.jpg" alt="stargazer_regression" width="510" height="590" class="aligncenter size-full wp-image-60900" /></a></p>
<h3>Many supported models</h3>
<p><b>stargazer</b> supports objects from the most widely used statistical functions and packages. These include objects from betareg (betareg), coxph (survival), clm (ordinal), clogit (survival), ergm (ergm),gam (mgcv), gee (gee), glm (stats), glmer (lme4), gls (nlme), hurdle (pscl), ivreg (AER), lm (stats), lmer (lme4), lmrob (robustbase), multinom (nnet), nlmer (lme4), plm (plm), pmg (plm), polr (MASS), rlm (MASS), svyglm (survey), survreg (survival), tobit (AER), zeroinfl (pscl), as well as from the implementation of these in Zelig. In addition, <b>stargazer</b> also supports several Zelig models for social network analysis: <b>cloglog.net</b>, <b>gamma.net</b>, <b>probit.net</b>, and <b>logit.net</b>. The number of models and objects can <b>stargazer</b> can accommodate puts it ahead of most of the alternative R-to-LaTeX options. As the development of the package continues, this list will continue expanding to include linear mixed effects models, matching models, as well as new, user-made, or customized statistical models.</p>
<h3>Beautiful aesthetics</h3>
<p><b>stargazer</b> is very pleasing to the eye, and allows the user to customize the formatting of the resulting table, including all variable labels. Below is an example of a good-looking, complex regression table created by <b>stargazer</b>:</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_complex_table.jpg"><img src="http://www.r-statistics.com/wp-content/uploads/2013/01/stargazer_complex_table-237x300.jpg" alt="stargazer_complex_table" width="237" height="300" class="aligncenter size-medium wp-image-60898" /></a><br />
&nbsp;</p>
<p>If you’d like to create tables that look like those from your discipline’s leading journal, <b>stargazer</b> can help you with that as well. You can use the <b>style</b> argument to choose a template of your choice. Economics and management scholars can thus create tables that resemble those published in the <i>American Economic Review</i>, in the <i>Quarterly Journal of Economics</i>, or in <i>Administrative Science Quarterly</i>. Political scientists can avail themselves of templates based on the <i>American Political Science Review</i>, the <i>American Journal of Political Science</i>, and on <i>International Organization.</i> For sociologists and demographers, the<i> American Sociological Review</i>, the <i>American Sociological Reviews </i>and <i>Demography</i> are available.</p>
<p><b>stargazer</b>, of course, is not the only R package that creates LaTeX code from R statistical output. Other packages with similar capabilities include <b>apsrtable</b>, <b>xtable</b>, <b>memisc</b>, <b>texreg</b> and <b>outreg</b>. Each of these has its own strengths and weaknesses, and users should explore all of them to find the best fit for their needs.</p>
<h3>Some extra Q&#038;A with Marek Hlavac (the package author)</h3>
<p><strong>What was your motivation for starting the package?  (self use, for students, for other people etc.)</strong></p>
<p>As a doctoral student in Political Economy and Government at Harvard University, I saw an urgent need for an easy-to-use tool to create well-formatted stargazer tables. Although other packages were available for this task, none of them combined a large number of supported models, good aesthetics, and simplicity of use in a way that I thought would be ideal.</p>
<p><strong>Why is the &#8220;summary&#8221; parameter turned on as default for data.frames? </strong></p>
<p>In published papers in the social sciences, summary statistics table are found more commonly than direct print-outs of chunks of data sets. For this reason, I thought the stargazer package should default to the user&#8217;s most likely need.</p>
<p><strong>This has been a guest post by Marek Hlavac, the author of the <a href="http://cran.r-project.org/web/packages/stargazer/index.html">{stargazer}</a> R package for beautiful LaTeX tables from R&#8217;s statistical models&#8217; outputs</strong>.</p>
<p>Finishing note: You (the readers) are invited to leave a comment to the author, or suggest your own guest post here, by <a href="http://www.r-statistics.com/contact-me/">contacting me</a>.</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/01/stargazer-package-for-beautiful-latex-tables-from-r-statistical-models-output/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>100 most read R posts for 2012 (stats from R-bloggers) &#8211; big data, visualization, data manipulation, and other languages</title>
		<link>http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/</link>
		<comments>http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/#comments</comments>
		<pubDate>Tue, 01 Jan 2013 12:03:45 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R and the web]]></category>
		<category><![CDATA[R bloggers]]></category>
		<category><![CDATA[R community]]></category>
		<category><![CDATA[R links]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60880</guid>
		<description><![CDATA[R-bloggers.com is now three years young. The site is an (unofficial) online journal of the R statistical programming environment, written by bloggers who agreed to contribute their R articles to the site. Last year, I posted on the top 24 R &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p><a href="http://www.r-bloggers.com/">R-bloggers.com</a> is now three years young. The site is an (unofficial) online journal of the R statistical programming environment, written by bloggers who agreed to contribute their R articles to the site.</p>
<p>Last year, I posted on <a href="http://www.r-statistics.com/2012/01/top-20-r-posts-of-2011-and-some-r-bloggers-statistics/">the top 24 R posts of 2011</a>. In this post I wish to celebrate R-bloggers’ third birthmounth by sharing with you:</p>
<ol>
<li>Links to the top <strong>100</strong> most read R posts of 2012</li>
<li>Statistics on “how well” R-bloggers did this year</li>
<li>My wishlist for the R community for 2013 (blogging about R, guest posts, and sponsors)</li>
</ol>
<h3>1. Top 100 R posts of 2012</h3>
<p>R-bloggers’ success is thanks to the content submitted by the over 400 R bloggers who have joined <a href="http://www.r-bloggers.com/add-your-blog/">r-bloggers</a>.  The R community currently has around <strong>245 active R bloggers</strong> (links to the blogs are clearly visible in the right navigation bar on the <a href="http://www.r-bloggers.com/">R-bloggers homepage</a>).  In the past year, these bloggers wrote around 3200 posts about R!</p>
<p>Here is a <strong>list of the top visited posts</strong> on the site in 2012 (you can see the number of unique visitors in parentheses, while the list is ordered by the number of total page views):</p>
<p><span id="more-60880"></span></p>
<ol>
<li><a href="http://r-bloggers.com/select-operations-on-r-data-frames/">Select operations on R data frames (42,742)</a></li>
<li><a href="http://r-bloggers.com/julia-i-love-you/">Julia, I Love You (22,405)</a></li>
<li><a href="http://r-bloggers.com/r-at-12000-cores/">R at 12,000 Cores (22,584)</a></li>
<li><a href="http://r-bloggers.com/an-r-programmer-looks-at-julia/">An R programmer looks at Julia (17,172)</a></li>
<li><a href="http://r-bloggers.com/adding-a-legend-to-a-plot/">Adding a legend to a plot (16,413)</a></li>
<li><a href="http://r-bloggers.com/solving-easy-problems-the-hard-way/">Solving easy problems the hard way (13,201)</a></li>
<li><a href="http://r-bloggers.com/the-best-statistical-programming-language-is-?€¦javascript/">The Best Statistical Programming Language is …Javascript? (11,047)</a></li>
<li><a href="http://r-bloggers.com/step-up-your-r-capabilities-with-new-tools-for-increased-productivity/">Step up your R capabilities with new tools for increased productivity (9,758)</a></li>
<li><a href="http://r-bloggers.com/how-i-cracked-troyis-the-online-flash-game/">How I cracked Troyis (the online flash game) (9,527)</a></li>
<li><a href="http://r-bloggers.com/setting-graph-margins-in-r-using-the-par-function-and-lots-of-cow-milk/">Setting graph margins in R using the par() function and lots of cow milk (9,549)</a></li>
<li><a href="http://r-bloggers.com/creating-surface-plots/">Creating surface plots (8,705)</a></li>
<li><a href="http://r-bloggers.com/running-r-on-an-iphoneipad-with-rstudio/">Running R on an iPhone/iPad with RStudio (8,903)</a></li>
<li><a href="http://r-bloggers.com/drawing-heatmaps-in-r/">Drawing heatmaps in R (8,719)</a></li>
<li><a href="http://r-bloggers.com/a-big-list-of-the-things-r-can-do/">A big list of the things R can do (8,152)</a></li>
<li><a href="http://r-bloggers.com/two-sample-students-t-test-1/">Two sample Student’s t-test #1 (8,112)</a></li>
<li><a href="http://r-bloggers.com/paired-students-t-test/">Paired Student’s t-test (7,950)</a></li>
<li><a href="http://r-bloggers.com/installing-r-packages/">Installing R packages (7,999)</a></li>
<li><a href="http://r-bloggers.com/multiple-y-axis-in-a-r-plot/">Multiple Y-axis in a R plot (7,486)</a></li>
<li><a href="http://r-bloggers.com/r-tutorial-series-labeling-data-points-on-a-plot/">R Tutorial Series: Labeling Data Points on a Plot (7,375)</a></li>
<li><a href="http://r-bloggers.com/color-palettes-in-r/">Color Palettes in R (6,656)</a></li>
<li><a href="http://r-bloggers.com/plot-maps-like-a-boss/">Plot maps like a boss (6,898)</a></li>
<li><a href="http://r-bloggers.com/model-validation-interpreting-residual-plots/">Model Validation: Interpreting Residual Plots (6,763)</a></li>
<li><a href="http://r-bloggers.com/find-xargs-like-a-boss/">find | xargs … Like a Boss (7,001)</a></li>
<li><a href="http://r-bloggers.com/getting-started-with-sweave-r-latex-eclipse-statet-texlipse/">Getting Started with Sweave: R, LaTeX, Eclipse, StatET, &amp; TeXlipse (6,775)</a></li>
<li><a href="http://r-bloggers.com/r-tutorial-series-r-beginners-guide-and-r-bloggers-updates/">R Tutorial Series: R Beginner’s Guide and R Bloggers Updates (6,703)</a></li>
<li><a href="http://r-bloggers.com/the-r-apply-function-?€“-a-tutorial-with-examples/">The R apply function – a tutorial with examples (6,764)</a></li>
<li><a href="http://r-bloggers.com/delete-rows-from-r-data-frame/">Delete rows from R data frame (6,243)</a></li>
<li><a href="http://r-bloggers.com/polynomial-regression-techniques/">Polynomial regression techniques (6,396)</a></li>
<li><a href="http://r-bloggers.com/why-r-is-hard-to-learn/">Why R is Hard to Learn (6,281)</a></li>
<li><a href="http://r-bloggers.com/basic-introduction-to-ggplot2/">Basic Introduction to ggplot2 (6,107)</a></li>
<li><a href="http://r-bloggers.com/trading-using-garch-volatility-forecast/">Trading using Garch Volatility Forecast (5,886)</a></li>
<li><a href="http://r-bloggers.com/will-2015-be-the-beginning-of-the-end-for-sas-and-spss/">Will 2015 be the Beginning of the End for SAS and SPSS? (5,924)</a></li>
<li><a href="http://r-bloggers.com/fun-with-the-googlevis-package-for-r/">Fun with the googleVis Package for R (5,495)</a></li>
<li><a href="http://r-bloggers.com/creating-beautiful-maps-with-r/">Creating beautiful maps with R (5,576)</a></li>
<li><a href="http://r-bloggers.com/tutorial-principal-components-analysis-pca-in-r/">Tutorial: Principal Components Analysis (PCA) in R (4,907)</a></li>
<li><a href="http://r-bloggers.com/wilcoxon-mann-whitney-rank-sum-test-or-test-u/">Wilcoxon-Mann-Whitney rank sum test (or test U) (5,574)</a></li>
<li><a href="http://r-bloggers.com/introducing-shiny-easy-web-applications-in-r/">Introducing Shiny: Easy web applications in R (5,501)</a></li>
<li><a href="http://r-bloggers.com/r-is-the-easiest-language-to-speak-badly/">R is the easiest language to speak badly (5,583)</a></li>
<li><a href="http://r-bloggers.com/r-2-15-0-is-released/">R 2.15.0 is released (5,486)</a></li>
<li><a href="http://r-bloggers.com/basics-on-markov-chain-for-parents/">Basics on Markov Chain (for parents) (5,395)</a></li>
<li><a href="http://r-bloggers.com/pivot-tables-in-r/">Pivot tables in R (5,320)</a></li>
<li><a href="http://r-bloggers.com/displaying-data-using-level-plots/">Displaying data using level plots (4,942)</a></li>
<li><a href="http://r-bloggers.com/r-tutorial-series-basic-polynomial-regression/">R Tutorial Series: Basic Polynomial Regression (5,165)</a></li>
<li><a href="http://r-bloggers.com/merging-multiple-data-files-into-one-data-frame/">Merging Multiple Data Files into One Data Frame (5,083)</a></li>
<li><a href="http://r-bloggers.com/quick-introduction-to-ggplot2/">Quick Introduction to ggplot2 (5,060)</a></li>
<li><a href="http://r-bloggers.com/summarising-data-using-box-and-whisker-plots/">Summarising data using box and whisker plots (4,953)</a></li>
<li><a href="http://r-bloggers.com/make-r-speak-sql-with-sqldf/">Make R speak SQL with sqldf (4,745)</a></li>
<li><a href="http://r-bloggers.com/mysql-and-r/">MySQL and R (4,595)</a></li>
<li><a href="http://r-bloggers.com/ggheat-a-ggplot2-style-heatmap-function/">ggheat : a ggplot2 style heatmap function (4,578)</a></li>
<li><a href="http://r-bloggers.com/aggregate-function-in-r-making-your-life-easier-one-mean-at-a-time/">Aggregate Function in R: Making your life easier, one mean at a time (4,756)</a></li>
<li><a href="http://r-bloggers.com/the-role-of-statistics-in-the-higgs-boson-discovery/">The role of Statistics in the Higgs Boson discovery (4,560)</a></li>
<li><a href="http://r-bloggers.com/plotting-time-series-data-using-ggplot2/">Plotting Time Series data using ggplot2 (4,543)</a></li>
<li><a href="http://r-bloggers.com/the-kalman-filter-for-financial-time-series/">The Kalman Filter For Financial Time Series (4,367)</a></li>
<li><a href="http://r-bloggers.com/r-101-the-subset-function/">R 101: The Subset Function (4,626)</a></li>
<li><a href="http://r-bloggers.com/create-your-own-beamer-template/">Create your own Beamer template (4,569)</a></li>
<li><a href="http://r-bloggers.com/mining-facebook-data-most-liked-status-and-friendship-network/">Mining Facebook Data: Most &#8220;Liked&#8221; Status and Friendship Network (4,493)</a></li>
<li><a href="http://r-bloggers.com/the-many-uses-of-q-q-plots/">The Many Uses of Q-Q Plots (4,376)</a></li>
<li><a href="http://r-bloggers.com/social-network-analysis-with-r/">Social Network Analysis with R (4,307)</a></li>
<li><a href="http://r-bloggers.com/20-free-r-tutorials-and-one-reference-card/">20 free R tutorials (and one reference card) (4,227)</a></li>
<li><a href="http://r-bloggers.com/to-attach-or-not-attach-that-is-the-question/">To attach() or not attach(): that is the question (4,439)</a></li>
<li><a href="http://r-bloggers.com/add-your-blog/">add your blog! | R-bloggers (3,941)</a></li>
<li><a href="http://r-bloggers.com/learn-r-and-python-and-have-fun-doing-it/">Learn R and Python, and Have Fun Doing It (4,205)</a></li>
<li><a href="http://r-bloggers.com/creating-a-presentation-with-latex-beamer-?€“-using-overlays/">Creating a Presentation with LaTeX Beamer – Using Overlays (4,319)</a></li>
<li><a href="http://r-bloggers.com/summarising-data-using-dot-plots/">Summarising data using dot plots (4,078)</a></li>
<li><a href="http://r-bloggers.com/google-summer-of-code-2012-and-r-a-call-for-students/">Google summer of code 2012 – and R – a call for students (4,180)</a></li>
<li><a href="http://r-bloggers.com/nice-ggplot-intro-tutorial-just-run-the-commands-about-6-pages/">nice ggplot intro tutorial. Just run the commands, about 6 pages… (3,902)</a></li>
<li><a href="http://r-bloggers.com/tracking-hurricane-sandy-with-open-data-and-r/">Tracking Hurricane Sandy with Open Data and R (4,108)</a></li>
<li><a href="http://r-bloggers.com/time-series-analysis-and-mining-with-r/">Time Series Analysis and Mining with R (3,874)</a></li>
<li><a href="http://r-bloggers.com/linear-mixed-models-in-r/">Linear mixed models in R (3,846)</a></li>
<li><a href="http://r-bloggers.com/a-graphical-overview-of-your-mysql-database/">A graphical overview of your MySQL database (3,919)</a></li>
<li><a href="http://r-bloggers.com/updating-r-but-keeping-your-installed-packages/">Updating R but keeping your installed packages (3,317)</a></li>
<li><a href="http://r-bloggers.com/data-table-rocks-data-manipulation-the-fast-way-in-r/">Data.table rocks! Data manipulation the fast way in R (3,691)</a></li>
<li><a href="http://r-bloggers.com/generating-graphs-of-retweets-and-messages-on-twitter-using-r-and-gephi/">Generating graphs of retweets and @-messages on Twitter using R and Gephi (3,623)</a></li>
<li><a href="http://r-bloggers.com/amateur-mapmaking-getting-started-with-shapefiles/">Amateur Mapmaking: Getting Started With Shapefiles (3,656)</a></li>
<li><a href="http://r-bloggers.com/datasets-to-practice-your-data-mining/">Datasets to Practice Your Data Mining (3,782)</a></li>
<li><a href="http://r-bloggers.com/how-to-customize-ggplot2-graphics/">How to customize ggplot2 graphics (3,720)</a></li>
<li><a href="http://r-bloggers.com/interactive-html-presentation-with-r-googlevis-knitr-pandoc-and-slidy/">Interactive HTML presentation with R, googleVis, knitr, pandoc and slidy (3,599)</a></li>
<li><a href="http://r-bloggers.com/the-undiscovered-country-?€“-a-tutorial-on-plotting-maps-in-r/">The undiscovered country – a tutorial on plotting maps in R (3,560)</a></li>
<li><a href="http://r-bloggers.com/polar-histogram-pretty-and-useful/">polar histogram: pretty and useful (3,487)</a></li>
<li><a href="http://r-bloggers.com/classification-trees/">Classification Trees (3,545)</a></li>
<li><a href="http://r-bloggers.com/text-mining-to-word-cloud-app-with-r/">Text Mining to Word Cloud App with R (3,388)</a></li>
<li><a href="http://r-bloggers.com/top-20-r-posts-of-2011-and-some-r-bloggers-statistics/">Top 20 R posts of 2011 (and some R-bloggers statistics) (3,606)</a></li>
<li><a href="http://r-bloggers.com/combining-ggplot-images/">Combining ggplot Images (3,492)</a></li>
<li><a href="http://r-bloggers.com/integrating-php-and-r/">Integrating PHP and R (3,420)</a></li>
<li><a href="http://r-bloggers.com/tutorials-for-learning-visualization-in-r/">Tutorials for Learning Visualization in R (3,509)</a></li>
<li><a href="http://r-bloggers.com/rstudio-in-the-cloud-for-dummies/">RStudio in the cloud, for dummies (3,402)</a></li>
<li><a href="http://r-bloggers.com/london-olympics-100m-mens-sprint-results/">London Olympics 100m men’s sprint results (3,460)</a></li>
<li><a href="http://r-bloggers.com/online-resources-for-handling-big-data-and-parallel-computing-in-r/">Online resources for handling big data and parallel computing in R (3,383)</a></li>
<li><a href="http://www.r-bloggers.com/the-higgs-boson-5-sigma-and-the-concept-of-p-values/">The Higgs boson: 5-sigma and the concept of p-values (3,339)</a></li>
<li><a href="http://r-bloggers.com/interactive-reports-in-r-with-knitr-and-rstudio/">Interactive reports in R with knitr and RStudio (3,296)</a></li>
<li><a href="http://r-bloggers.com/maps-with-r-i/">Maps with R (I) (3,283)</a></li>
<li><a href="http://r-bloggers.com/ggplot2-time-series-heatmaps/">ggplot2 Time Series Heatmaps (3,262)</a></li>
<li><a href="http://r-bloggers.com/simple-text-mining-with-r/">Simple Text Mining with R (3,174)</a></li>
<li><a href="http://r-bloggers.com/contingency-tables-?€“-fisher?€™s-exact-test/">Contingency Tables – Fisher’s Exact Test (3,250)</a></li>
<li><a href="http://r-bloggers.com/an-example-of-roc-curves-plotting-with-rocr/">An example of ROC curves plotting with ROCR (3,202)</a></li>
<li><a href="http://r-bloggers.com/great-maps-with-ggplot2/">Great Maps with ggplot2 (3,155)</a></li>
<li><a href="http://r-bloggers.com/style-your-r-charts-like-the-economist-tableau-or-xkcd/">Style your R charts like the Economist, Tableau … or XKCD (3,218)</a></li>
<li><a href="http://r-bloggers.com/simple-linear-regression-2/">Simple Linear Regression (3,212)</a></li>
<li><a href="http://r-bloggers.com/a-practical-introduction-to-garch-modeling/">A practical introduction to garch modeling (3,158)</a></li>
<li><a href="http://r-bloggers.com/adding-lines-or-points-to-an-existing-barplot/">Adding lines or points to an existing barplot (3,057)</a></li>
</ol>
<p>&nbsp;</p>
<h3>2. Statistics – how well did R-bloggers do in 2012?</h3>
<p>Short answer: quite well.</p>
<p>In 2012, R-bloggers has reached around 11,000 regular subscribers (which you can also subscribe to: via <a href="http://feeds.feedburner.com/RBloggers">RSS</a>, or <a href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">e-mail</a>), serving the content of about 245 R bloggers.  In total, the site was visited around 2.7 million times, by over 1.1 million people.  Bellow you can see a few figures comparing the statistics of 2012 with those of 2011 (just click the image to enlarge it):</p>
<p style="text-align: center;"><a href="http://www.r-statistics.com/wp-content/uploads/2012/12/rbloggers_stats_2012_1.png"><img class="aligncenter  wp-image-60882" alt="rbloggers_stats_2012_1" src="http://www.r-statistics.com/wp-content/uploads/2012/12/rbloggers_stats_2012_1-300x143.png" width="300" height="143" /></a></p>
<p> <a href="http://www.r-statistics.com/wp-content/uploads/2012/12/rbloggers_stats_2012_2.png"><img class="aligncenter size-medium wp-image-60883" alt="rbloggers_stats_2012_2" src="http://www.r-statistics.com/wp-content/uploads/2012/12/rbloggers_stats_2012_2-300x57.png" width="300" height="57" /></a></p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/12/rbloggers_stats_2012_3.png"><img class="aligncenter size-medium wp-image-60884" alt="rbloggers_stats_2012_3" src="http://www.r-statistics.com/wp-content/uploads/2012/12/rbloggers_stats_2012_3-300x194.png" width="300" height="194" /></a></p>
<h3>3. My wishlist for 2013 &#8211; about the future of the R blogosphere</h3>
<p>Well now, this has been an AMAZING year for the R-project in general, the R community, and consequently also for R-bloggers.  Here are a few things I wish for 2013:</p>
<p><strong>Reproducible R blogging &#8211; make it to blog from R to WordPress and blogger (via knitr, RStudio, etc.)</strong></p>
<p>The past year has been wonderful regarding progress in making reproducible research with R using Sweave, knitr, RStudio, and many new R packages.  For 2013 I wish someone (or some-company, RStudio, cough cough) would take on themselves to make it as easy as possible to do Reproducible R blogging.  The seeds are already there, thanks to people like JJ Allaire, Jeffrey Horner, Vicent Marti, and Natacha Porte we now have the markdown package, which combined with Yihui Xie <a href="http://cran.r-project.org/web/packages/knitr/index.html">knitr package</a> and the wonderful <a href="http://www.rstudio.com/">RStudio</a> (R IDE), allows us all to easily create HTML documents of R analysis.  Combine this with something like one of Duncan Temple Lang&#8217;s R packages (<a href="http://www.omegahat.org/XMLRPC/">XMLRPC</a>, <a href="http://www.omegahat.org/RWordPress/">RWordPress</a>) and one can imagine the future.</p>
<p>The next step will be to have a &#8220;<strong>publish to your WordPress/blogger</strong>&#8221; button right from the RStudio console &#8211; allowing for the smoothest R blogging experience one could dream of.</p>
<p>I hope we&#8217;ll see this as early as possible in 2013.</p>
<p><strong>Creating online interactive visualization using R</strong></p>
<p>There can never be enough of this really.</p>
<p>So far, I should give props to Markus Gesmann, Diego de Castillo for authoring and maintaining <a href="http://cran.r-project.org/web/packages/googleVis/index.html">the awesome googleVis R package</a>.  This package is great for online publishing of interesting results.  For example, see the site<a href="http://statil.org/"> StatIL.org &#8211; visualizing over 25,000 Time series of Israel&#8217;s statistics</a> using html files produced (also) with the googleVis package (example: <a href="http://statil.org/Population/263/3700/#interactive">population of Israel between 1950 to 2011</a>).</p>
<p>The second promising project is <a href="http://cran.r-project.org/web/packages/shiny/index.html">Shiny</a>, which Shiny makes it incredibly easy to build interactive web applications with R. Since they intend to release an open source server of Shiny, which can run on Apache, we can expect very interesting developments on that front this year.</p>
<p><strong>More guest posts on R-bloggers</strong></p>
<p>If you have valuable knowledge and insights to share with the R community, the best way I suggest is to start your own free blog on <a href="http://WordPress.com">WordPress.com</a>.  Create a dedicated R category for your R posts, and<a href="http://www.r-bloggers.com/add-your-blog/"> ask to join r-bloggers</a> (make sure to read and follow the guidelines mentioned there).</p>
<p>This year I am considering allowing non-bloggers to also take part in the party.  The idea is to create a simple form which will allow you to write a guest article which (after review) will go live on r-bloggers (without the need to first start your own blog).  If you are interested to submit such a guest article in the future (even if you are not sure exactly what you will write about), <a href="https://docs.google.com/spreadsheet/embeddedform?formkey=dHoyZlJzVE9FU1JRTXRHYzdHY21LT2c6MQ">please fill out this form with your e-mail</a>.  IF I see people are interested, I will go ahead and create this service.</p>
<p><strong><strong>Your help in sharing/linking-to R-bloggers.com</strong></strong></p>
<p><strong>Sharing</strong>: If you don&#8217;t alreayd know, R-bloggers is not a company.  The site is run by just one guy (<a href="http://www.r-statistics.com/about/">Tal Galili</a>).  There is no marketing team, marketing budget, or any campaign.  The only people who know about the site are your and the people YOU will send the link to (through facebook, your personal website, blog, etc.).  So if you haven&#8217;t already &#8211; please help share r-bloggers.com in whatever way you can online.</p>
<p><strong><strong>Subscribe to R-bloggers.com</strong></strong></p>
<p>You can also subscribe to daily updates of new R posts via <a href="http://feeds.feedburner.com/RBloggers">RSS</a>, or by filling in your <a href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">e-mail</a> address (I don&#8217;t give it to strangers, I promise).  You can also <a href="http://www.facebook.com/pages/R-bloggers/191414254890">join the R-bloggers facebook page</a>, but make sure (once liked) to press the &#8220;like&#8221; button and mark V by &#8220;get notifications&#8221; and &#8220;show in news feed&#8221; (see in the image bellow)</p>
<p>&nbsp;</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2013/01/rbloggers_stats_2012_4.png"><img class="aligncenter size-medium wp-image-60887" alt="rbloggers_stats_2012_4" src="http://www.r-statistics.com/wp-content/uploads/2013/01/rbloggers_stats_2012_4-300x174.png" width="300" height="174" /></a></p>
<p><strong><strong>Sponsoring</strong></strong></p>
<p>If you are interested in sponsoring/placing-ads/supporting R-bloggers, then you are welcome to <a href="http://www.r-statistics.com/contact-me/">contact me</a>.  Currently there is not much place left, but you can still contact me and I will update you once an ad placement is freed up.</p>
<p><strong>Stay in touch <img src='http://www.r-statistics.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p>
<p>As always, you are welcome to leave a comment on this blog, and/or <a href="http://www.r-statistics.com/contact-me/">contact me</a> (keeping in mind it might take me some time to get back to you, but I promise I will).</p>
<p>&nbsp;</p>
<p>Happy new year!<br />
Yours truly,<br />
Tal Galili</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2013/01/100-most-read-r-posts-for-2012-stats-from-r-bloggers-big-data-visualization-data-manipulation-and-other-languages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Generation of E-Learning Exams in R for Moodle, OLAT, etc.</title>
		<link>http://www.r-statistics.com/2012/12/generation-of-e-learning-exams-in-r-for-moodle-olat-etc/</link>
		<comments>http://www.r-statistics.com/2012/12/generation-of-e-learning-exams-in-r-for-moodle-olat-etc/#comments</comments>
		<pubDate>Thu, 20 Dec 2012 12:11:25 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R and the web]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[Achim Zeileis]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[Exams]]></category>
		<category><![CDATA[moodle]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[packages]]></category>
		<category><![CDATA[teachers]]></category>
		<category><![CDATA[teaching]]></category>
		<category><![CDATA[teaching statistics]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60857</guid>
		<description><![CDATA[(Guest post by Achim Zeileis) Development of the R package exams for automatic generation of (statistical) exams in R started in 2006 and version 1 was published in JSS by Grün and Zeileis (2009). It was based on standalone Sweave exercises, that can be combined &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2012/12/generation-of-e-learning-exams-in-r-for-moodle-olat-etc/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2012/12/generation-of-e-learning-exams-in-r-for-moodle-olat-etc/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>(Guest post by <a href="http://eeecon.uibk.ac.at/~zeileis/" target="_blank">Achim Zeileis</a>)<br />
Development of the R package <a href="http://CRAN.R-project.org/package=exams" target="_blank">exams</a> for automatic generation of (statistical) exams in R started in 2006 and version 1 was published in JSS by <a href="http://www.jstatsoft.org/v29/i10/" target="_blank">Grün and Zeileis (2009)</a>. It was based on standalone <tt><a href="http://www.stat.uni-muenchen.de/~leisch/Sweave/" target="_blank">Sweave</a> </tt>exercises, that can be combined into exams, and then rendered into different kinds of PDF output (exams, solutions, self-study materials, etc.). Now, a major revision of the package has been released that extends the capabilities and adds support for learning management systems. It is still based on the <em>same</em> type of<br />
<tt>Sweave</tt> files for each exercise but can also render them into output formats like HTML (with various options for displaying mathematical content) and XML specifications for online exams in learning management systems such as <a href="http://moodle.org/" target="_blank">Moodle</a> or <a href="http://www.olat.org/" target="_blank">OLAT</a>. Supplementary files such as graphics or data are<br />
handled automatically. Here, I give a brief overview of the new capabilities. A detailed discussion is in the working paper by <a href="http://EconPapers.RePEc.org/RePEc:inn:wpaper:2012-27" target="_blank">Zeileis, Umlauf, and Leisch (2012)</a> that is also contained in the package as a vignette.<br />
<span id="more-60857"></span></p>
<h3>The basic idea&#8230;</h3>
<p>&#8230;is to have standard standalone <tt>Sweave</tt> files for each exercise. These typically comprise (1) R code chunks (as usual within <tt>&lt;&lt;&gt;&gt;=</tt> and <tt>@</tt>) for random data generation. (2) Question and solution descriptions contained in LaTeX environments of corresponding names, typically with <tt>\Sexpr{}</tt> for including data<br />
for the question. (3) Metainformation about the exercise type (numeric, multiple choice, &#8230;), its correct solution etc. Then many different replications of (collections of) such an exercise can be easily created by repeating the following four steps:<br />
<em>Weaving</em> the exercise (i.e., executing the R code for random data generation and embedding that into the text), <em>reading</em> the resulting LaTeX into R, <em>transforming</em> the LaTeX to another format such as HTML (if necessary), <em>writing</em> the corresponding output files, e.g., in PDF, HTML, XML, &#8230;<br />
The package provides convenience interfaces <tt>exams2pdf()</tt>, <tt>exams2html()</tt>, <tt>exams2moodle()</tt>, and <tt>exams2qti12()</tt> (for OLAT) that directly carry out all of these steps but the package also provides the underlying building blocks such that new interfaces can be easily created.</p>
<h3>A simple example</h3>
<p>To get a quick impression of the look and feel of the package, consider the following simple example: computation of a <i>t</i> statistic from given mean, variance, and sample size. The corresponding <tt>Sweave</tt> template <tt>tstat.Rnw</tt> is provided within the package. After installing the package, you can produce random versions of this exercise in PDF and HTML by running the following code:</p>

<div class="wp_codebox"><table><tr id="p6085743"><td class="code" id="p60857code43"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;exams&quot;</span><span style="color: #080;">&#41;</span>
exams2pdf<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;tstat.Rnw&quot;</span><span style="color: #080;">&#41;</span>
exams2html<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;tstat.Rnw&quot;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>The former needs a working LaTeX installation and then pops up a PDF with the exercise.<br />
The latter does not need LaTeX but just the R package <a href="http://CRAN.R-project.org/package=tth" target="_blank">tth</a> (interfacing Ian Hutchinson&#8217;s wonderful <a href="http://hutchinson.belmont.ma.us/tth/" target="_blank">TtH</a><br />
TeX-to-HTML converter) and then pops up the HTML with the exercise in a browser.<br />
<a href="http://en.wikipedia.org/wiki/MathML" target="_blank">MathML</a> support is needed for this version of the HTML exercise, e.g., by using the Firefox browser.</p>
<h3>How it works</h3>
<p>The <tt>tstat.Rnw</tt> is a relatively simple <tt>Sweave</tt> file: It first draws some random data and then uses the textbook formula to compute the correct <i>t</i> statistic. Subsequently, there are two LaTeX environments with the <tt>{question}</tt> and <tt>{solution}</tt>, respectively. Finally, some simple metainformation is provided<br />
in LaTeX style (but commented):</p>
<pre>&lt;&gt;=
## DATA GENERATION
n n}}}
    = \frac{\Sexpr{Mean} - \Sexpr{mu}}{\sqrt{\frac{\<wbr />Sexpr{Var}}{\Sexpr{n}}}}
    = \Sexpr{tstat}.
  \end{eqnarray*}
  The absolute value of the $t$~test statistic is thus equal to
  $\Sexpr{format(abs(tstat), nsmall = 3)}$.
\end{solution}

%% META-INFORMATION
%% \extype{num}
%% \exsolution{\Sexpr{format(abs(<wbr />tstat), nsmall = 3)}}
%% \exname{t statistic}
%% \extol{0.01}</pre>
<p>After running <tt>Sweave()</tt> on it, the resulting LaTeX code has the random numbers filled in and the data-generating code omitted:</p>
<pre>\begin{question}
  A machine fills milk into $500$ml packages. It is suspected that the 
  machine is not working correctly and that the amount of milk filled differs 
  from the setpoint $\mu_0 = 500$. A sample of $226$ packages 
  filled by the machine are collected. The sample mean $\bar{y}$ is equal to 
  $517.2$ and the sample variance $s^2_{n-1}$ is equal to $262.56$.

  Test the hypothesis that the amount filled corresponds on average to the 
  setpoint. What is the absolute value of the $t$~test statistic?
\end{question}

\begin{solution}
  The $t$~test statistic is calculated by:
  \begin{eqnarray*}
    t &amp; = &amp; \frac{\bar y - \mu_0}{\sqrt{\frac{s^2_{n-1}}{<wbr />n}}}
    = \frac{517.2 - 500}{\sqrt{\frac{262.56}{226}}<wbr />}
    = 15.958.
  \end{eqnarray*}
  The absolute value of the $t$~test statistic is thus equal to
  $15.958$.
\end{solution}

%% META-INFORMATION
%% \extype{num}
%% \exsolution{15.958}
%% \exname{t statistic}
%% \extol{0.01}</pre>
<p>The LaTeX code is then read into R, can be transformed into HTML using <tt>tth()</tt>, embedded into a simple HTML file, and then shown in a browser:</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/12/exams2html-tstat.png" rel="attachment wp-att-60863"><img class="aligncenter size-medium wp-image-60863" alt="exams2html-tstat" src="http://www.r-statistics.com/wp-content/uploads/2012/12/exams2html-tstat-300x211.png" width="300" height="211" /></a></p>
<h3>Support for learning management systems</h3>
<p>The same HTML code shown in the example above can also be embedded into learning management<br />
systems. These typically have XML-based exchange formats, e.g., Moodle uses its own <a href="http://docs.moodle.org/23/en/Moodle_XML_format" target="_blank">Moodle XML</a><br />
while OLAT and several other systems use the international <a href="http://www.imsglobal.org/question/qtiv1p2/imsqti_asi_bindv1p2.html" target="_blank">IMS QTI 1.2</a> standard. The package provides functions <tt>exams2moodle()</tt> and <tt>exams2qti12() </tt>which provide output files that can be easily imported into Moodle and OLAT, respectively.<br />
As a result, the <tt>tstat.Rnw</tt> looks in Moodle like this:</p>
<p><a href="http://www.r-statistics.com/wp-content/uploads/2012/12/exams2moodle-tstat.png" rel="attachment wp-att-60862"><img class="aligncenter size-medium wp-image-60862" alt="exams2moodle-tstat" src="http://www.r-statistics.com/wp-content/uploads/2012/12/exams2moodle-tstat-300x120.png" width="300" height="120" /></a></p>
<p>Note that this now has a field for entering the answer (and only after that the correct solution<br />
can optionally be shown).</p>
<p>To generate a Moodle quiz with three random replications for five exercises drawn from collections<br />
of different templates, consider the following example (based on templates provided within the<br />
package):</p>

<div class="wp_codebox"><table><tr id="p6085744"><td class="code" id="p60857code44"><pre class="rsplus" style="font-family:monospace;">myexam <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span>
  <span style="color: #ff0000;">&quot;boxplots&quot;</span>,
  <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;confint&quot;</span>, <span style="color: #ff0000;">&quot;ttest&quot;</span>, <span style="color: #ff0000;">&quot;tstat&quot;</span><span style="color: #080;">&#41;</span>,
  <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;anova&quot;</span>, <span style="color: #ff0000;">&quot;regression&quot;</span><span style="color: #080;">&#41;</span>,
  <span style="color: #ff0000;">&quot;scatterplot&quot;</span>,
  <span style="color: #ff0000;">&quot;relfreq&quot;</span><span style="color: #080;">&#41;</span>
exams2moodle<span style="color: #080;">&#40;</span>myexam, n <span style="color: #080;">=</span> <span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>This produces a file <tt>moodlequiz.xml</tt> that can be imported into the question bank in Moodle. (In this step, the HTML markup for formulas and graphics is not formatted by Moodle but don&#8217;t worry: the final quiz will render correctly.) Subsequently, all replications of each exercise can be added as &#8220;random&#8221; questions into the quiz. Some more configuration of the quiz as a whole can then be done in Moodle but otherwise everything else is ready for the participants of the quiz.</p>
<h3>If you want to use this for your own course&#8230;</h3>
<ul>
<li>You need an installation of a suitable learning management system but many universities have<br />
support for this anyway.</li>
<li>You need to build your collection of <tt>Sweave</tt> exercise templates. This is, of course,<br />
the most work. However, the package provides a suite of examples that can be helpful as<br />
starting points.</li>
<li>You need to export the exams/quizzes/assessments from R to the correct format for the<br />
learning management system. Moodle and OLAT are directly supported. But through QTI 1.2<br />
other systems could, in principle, be interfaced as well. We haven&#8217;t tested this yet, though.</li>
</ul>
<p>More details are provided in the <a href="http://EconPapers.RePEc.org/RePEc:inn:wpaper:2012-27" target="_blank">working paper</a> and we also provide a <a href="http://r-forge.r-project.org/forum/?group_id=1337" target="_blank">support forum</a> on R-Forge if you experience any problems etc.</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2012/12/generation-of-e-learning-exams-in-r-for-moodle-olat-etc/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/12/generation-of-e-learning-exams-in-r-for-moodle-olat-etc/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Comparing Shiny with gWidgetsWWW2.rapache</title>
		<link>http://www.r-statistics.com/2012/11/comparing-shiny-with-gwidgetswww2-rapache/</link>
		<comments>http://www.r-statistics.com/2012/11/comparing-shiny-with-gwidgetswww2-rapache/#comments</comments>
		<pubDate>Mon, 12 Nov 2012 21:34:48 +0000</pubDate>
		<dc:creator>Tal Galili</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[R and the web]]></category>
		<category><![CDATA[R programming]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[gWidgets]]></category>
		<category><![CDATA[John Verzani]]></category>
		<category><![CDATA[R GUI]]></category>
		<category><![CDATA[RApache]]></category>
		<category><![CDATA[statistical applications]]></category>
		<category><![CDATA[statistical apps]]></category>
		<category><![CDATA[statistics as a service]]></category>

		<guid isPermaLink="false">http://www.r-statistics.com/?p=60799</guid>
		<description><![CDATA[(A guest post by John Verzani) A few days back the RStudio blog announced Shiny, a new product for easily creating interactive web applications (http://www.rstudio.com/shiny/). I wanted to compare this new framework to one I&#8217;ve worked on, gWidgetsWWW2.rapache – a version of &#8230;<p class="read-more"><a href="http://www.r-statistics.com/2012/11/comparing-shiny-with-gwidgetswww2-rapache/">Read more &#187;</a></p>]]></description>
				<content:encoded><![CDATA[<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2012/11/comparing-shiny-with-gwidgetswww2-rapache/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div><p>(A guest post by <em><a href="http://wiener.math.csi.cuny.edu/verzani/">John Verzani</a></em>)</p>
<p>A few days back the RStudio blog announced Shiny, a new product for easily creating interactive web applications (<a href="http://www.rstudio.com/shiny/" target="_blank">http://www.rstudio.com/shiny/</a><wbr>). I wanted to compare this new framework to one I&#8217;ve worked on, <em>gWidgetsWWW2.rapache</em> – a version of the gWidgets API for use with Jeffrey Horner&#8217;s <em>rapache</em> module for the Apache web server (available at GitHub). The <em>gWidgets</em> API has a similar aim to make it easy for R users to create interactive applications.</wbr></p>
<p>I don&#8217;t want to worry here about deployment of apps, just the writing side. The <em>shiny</em> package uses websockets to transfer data back and forth from browser to server. Though this may cause issues with wider deployment, the industrious RStudio folks have a hosting program in beta for internet-wide deployment. For local deployment, no problems as far as I know – as long as you avoid older versions of internet explorer.</p>
<p>Now, Shiny seems well suited for applications where the user can parameterize a resulting graphic, so that was the point of comparison. Peter Dalgaard&#8217;s <em>tcltk</em> package ships with a classic demo <em>tkdensity.R</em>. I use that for inspiration below. That GUI allows the user a few selections to modify a density plot of a random sample.<br />
<span id="more-60799"></span></p>
<h2>gWidgetsWWW2</h2>
<p>We&#8217;ll start with a <em>gWidgets</em> approach and work our way to the <em>shiny</em> code. A basic GUI can be generated with the following code:</p>

<div class="wp_codebox"><table><tr id="p6079950"><td class="code" id="p60799code50"><pre class="rsplus" style="font-family:monospace;">&nbsp;
width <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">600</span><span style="color: #080;">;</span> height <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">480</span>
&nbsp;
<span style="color: #228B22;">## The plot commands. Uses GUI objects defined below</span>
make_plot <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>...<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
  y <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">get</span><span style="color: #080;">&#40;</span>svalue<span style="color: #080;">&#40;</span>distribution<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#40;</span>svalue<span style="color: #080;">&#40;</span>size<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">density</span><span style="color: #080;">&#40;</span>y, bw<span style="color: #080;">=</span>svalue<span style="color: #080;">&#40;</span>bandwidth<span style="color: #080;">&#41;</span><span style="color: #080;">/</span><span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">=</span>svalue<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">points</span><span style="color: #080;">&#40;</span>y, <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>, svalue<span style="color: #080;">&#40;</span>size<span style="color: #080;">&#41;</span> <span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
update_plot <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>...<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
  f <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">tempfile</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>canvas<span style="color: #080;">&#41;</span>
  canvas<span style="color: #080;">&#40;</span>f, width<span style="color: #080;">=</span>width, height<span style="color: #080;">=</span>height<span style="color: #080;">&#41;</span>
  make_plot<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
  <span style="color: #0000FF; font-weight: bold;">dev.<span style="">off</span></span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
  svalue<span style="color: #080;">&#40;</span>cnv<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> f <span style="color: #228B22;">## update canvas widget</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;">## The layout</span>
w <span style="color: #080;">&lt;-</span> gwindow<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;tkdensity example&quot;</span><span style="color: #080;">&#41;</span>
gstatusbar<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Powered by gWidgetsWWW2.rapache and rapache&quot;</span>, cont<span style="color: #080;">=</span>w<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">## containers</span>
bl <span style="color: #080;">&lt;-</span> gborderlayout<span style="color: #080;">&#40;</span>cont<span style="color: #080;">=</span>w<span style="color: #080;">&#41;</span>
fl <span style="color: #080;">&lt;-</span> gformlayout<span style="color: #080;">&#40;</span>cont<span style="color: #080;">=</span>bl, where<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;west&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">## controls</span>
distribution <span style="color: #080;">&lt;-</span> gcombobox<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span><span style="color: #080;">&#40;</span>value<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;rnorm&quot;</span>, <span style="color: #ff0000;">&quot;rexp&quot;</span><span style="color: #080;">&#41;</span>,
                                     <span style="color: #0000FF; font-weight: bold;">labels</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Normal&quot;</span>, <span style="color: #ff0000;">&quot;Exponential&quot;</span><span style="color: #080;">&#41;</span>,
                                     stringsAsFactors<span style="color: #080;">=</span>FALSE<span style="color: #080;">&#41;</span>,
                          cont<span style="color: #080;">=</span>fl, label<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;distribution&quot;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF; font-weight: bold;">kernel</span> <span style="color: #080;">&lt;-</span> gcombobox<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;gaussian&quot;</span>, <span style="color: #ff0000;">&quot;epanechnikov&quot;</span>, <span style="color: #ff0000;">&quot;rectangular&quot;</span>,
             <span style="color: #ff0000;">&quot;triangular&quot;</span>, <span style="color: #ff0000;">&quot;cosine&quot;</span><span style="color: #080;">&#41;</span>,
                    cont<span style="color: #080;">=</span>fl, label<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;kernel&quot;</span><span style="color: #080;">&#41;</span>
size <span style="color: #080;">&lt;-</span> gcombobox<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">5</span>,<span style="color: #ff0000;">50</span>, <span style="color: #ff0000;">100</span>, <span style="color: #ff0000;">200</span>, <span style="color: #ff0000;">300</span><span style="color: #080;">&#41;</span>,
                  coerce.<span style="">with</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;as.numeric&quot;</span>,
                  cont<span style="color: #080;">=</span>fl, label<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;size&quot;</span><span style="color: #080;">&#41;</span>
bandwidth <span style="color: #080;">&lt;-</span> gslider<span style="color: #080;">&#40;</span><span style="color: #ff0000;">0.05</span><span style="color: #080;">*</span><span style="color: #ff0000;">100</span>, <span style="color: #ff0000;">2</span><span style="color: #080;">*</span><span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">by</span><span style="color: #080;">=</span><span style="color: #ff0000;">0.05</span><span style="color: #080;">*</span><span style="color: #ff0000;">100</span>, value<span style="color: #080;">=</span><span style="color: #ff0000;">1</span><span style="color: #080;">*</span><span style="color: #ff0000;">100</span>,
                     width<span style="color: #080;">=</span><span style="color: #ff0000;">250</span>,
                     coerce.<span style="">with</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;as.numeric&quot;</span>,
                     cont<span style="color: #080;">=</span>fl, label<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;bandwidth&quot;</span><span style="color: #080;">&#41;</span>
refresh <span style="color: #080;">&lt;-</span> gbutton<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;refresh&quot;</span>,
                   cont<span style="color: #080;">=</span>fl, label<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
cnv <span style="color: #080;">&lt;-</span> gcanvas<span style="color: #080;">&#40;</span>cont<span style="color: #080;">=</span>bl, where<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;center&quot;</span>, width<span style="color: #080;">=</span>width, height<span style="color: #080;">=</span>height<span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;">## connect controls</span>
<span style="color: #0000FF; font-weight: bold;">for</span><span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #0000FF; font-weight: bold;">list</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">kernel</span>, size, bandwidth, refresh<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
  addHandlerChanged<span style="color: #080;">&#40;</span>i, update_plot<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>All right, that may look like a lot, but lots of people have used <em>gWidgets</em> to write such GUIs. They aren&#8217;t that hard. basically there are three parts:</p>
<ul>
<li>The definition of the controls and their layout that comprise the<br />
user interface.</li>
<li>The definition of some callback to create the graphic when a control<br />
is updated.</li>
<li>Some means to specify when to invoke this call back.</li>
</ul>
<p>The <em>gWidgets</em> API is meant to be cross-toolkit, but this is only mostly true. In the above we use a few web-specific features, including the <em>canvas</em> package to provide a <em>JavaScript</em> canvas for drawing R graphics.</p>
<h2>Manipulate</h2>
<p>This particular example would be really easy were we able to use RStudio&#8217;s <em>manipulate</em> package. That is only for RStudio users though. Well, not really. There is a simple map available in the <em>gWidgetsWWW2.rapache</em> package that allows us to easily use that specification. Here is the code:</p>

<div class="wp_codebox"><table><tr id="p6079951"><td class="code" id="p60799code51"><pre class="rsplus" style="font-family:monospace;">&nbsp;
<span style="color: #228B22;">## load in map for manipulate -&gt; gWidgets</span>
<span style="color: #0000FF; font-weight: bold;">source</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">system.<span style="">file</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;demo&quot;</span>, <span style="color: #ff0000;">&quot;manipulate.R&quot;</span>, package<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;gWidgetsWWW2.rapache&quot;</span><span style="color: #080;">&#41;</span>, <span style="color: #0000FF; font-weight: bold;">local</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span>
&nbsp;
w <span style="color: #080;">&lt;-</span> gwindow<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Manipulate example&quot;</span><span style="color: #080;">&#41;</span>
gstatusbar<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Powered by gWidgetsWWW2.rapache and rapache&quot;</span>, cont<span style="color: #080;">=</span>w<span style="color: #080;">&#41;</span>
&nbsp;
manipulate<span style="color: #080;">&#40;</span>
           <span style="color: #080;">&#123;</span>
             y <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">get</span><span style="color: #080;">&#40;</span>distribution<span style="color: #080;">&#41;</span><span style="color: #080;">&#40;</span>size<span style="color: #080;">&#41;</span>
             <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">density</span><span style="color: #080;">&#40;</span>y, bw<span style="color: #080;">=</span>bandwidth<span style="color: #080;">/</span><span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
             <span style="color: #0000FF; font-weight: bold;">points</span><span style="color: #080;">&#40;</span>y, <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>, size<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
           <span style="color: #080;">&#125;</span>,
           <span style="color: #228B22;">##</span>
           distribution<span style="color: #080;">=</span>picker<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Normal&quot;</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;rnorm&quot;</span>, <span style="color: #ff0000;">&quot;Exponential&quot;</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;rexp&quot;</span><span style="color: #080;">&#41;</span>,
           <span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">=</span>picker<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;gaussian&quot;</span>, <span style="color: #ff0000;">&quot;epanechnikov&quot;</span>, <span style="color: #ff0000;">&quot;rectangular&quot;</span>,
             <span style="color: #ff0000;">&quot;triangular&quot;</span>, <span style="color: #ff0000;">&quot;cosine&quot;</span><span style="color: #080;">&#41;</span>,
           size<span style="color: #080;">=</span>picker<span style="color: #080;">&#40;</span><span style="color: #ff0000;">5</span>, <span style="color: #ff0000;">50</span>, <span style="color: #ff0000;">100</span>, <span style="color: #ff0000;">200</span>, <span style="color: #ff0000;">300</span><span style="color: #080;">&#41;</span>,
           bandwidth<span style="color: #080;">=</span>slider<span style="color: #080;">&#40;</span><span style="color: #ff0000;">0.05</span> <span style="color: #080;">*</span> <span style="color: #ff0000;">100</span>, <span style="color: #ff0000;">2.00</span> <span style="color: #080;">*</span> <span style="color: #ff0000;">100</span>, <span style="color: #0000FF; font-weight: bold;">step</span><span style="color: #080;">=</span><span style="color: #ff0000;">0.05</span> <span style="color: #080;">*</span> <span style="color: #ff0000;">100</span>, initial<span style="color: #080;">=</span><span style="color: #ff0000;">1</span><span style="color: #080;">*</span> <span style="color: #ff0000;">100</span><span style="color: #080;">&#41;</span>, <span style="color: #228B22;"># integers needed</span>
           button<span style="color: #080;">=</span>button<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Refresh&quot;</span><span style="color: #080;">&#41;</span>,
           <span style="color: #228B22;">## gWidgetsWWW2.rapache extras</span>
           container<span style="color: #080;">=</span>w,       
           device<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;svg&quot;</span>,                <span style="color: #228B22;"># svg or canvas or png</span>
           <span style="color: #0000FF; font-weight: bold;">delay</span><span style="color: #080;">=</span><span style="color: #ff0000;">1000</span>                   <span style="color: #228B22;"># delay to let data load for combo boxes</span>
           <span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Okay, I admit. I&#8217;m a fan of <em>manipulate</em> and it really is a perfect way to specify an interface as straightforward as this. This one is an example in the <em>gWidgetsWWW2.rapache</em> package and you can see it in action at <a href="http://www.math.csi.cuny.edu/gw/ex-manipulate.R" target="_blank">http://www.math.csi.cuny.edu/<wbr>gw/ex-manipulate.R</wbr></a> (though this redirects to a private server which is often not online). The <em>manipulate</em> interface handles the layout of the controls and the invocation of the callback, all you add is an expression to plot and a specification of<br />
the controls. </p>
<h2>Shiny</h2>
<p>Now for Shiny. We noted above there are really three pieces to writing this app, with Shiny we only need to worry about two: the definition and layout of the user interface, and the specification of how the resulting graphic is made. For this, we write two functions: <em>ui.R</em> and <em>server.R</em>.</p>
<p>The <em>ui.R</em> files is used to layout the interface. Here is ours:</p>

<div class="wp_codebox"><table><tr id="p6079952"><td class="code" id="p60799code52"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span>shiny<span style="color: #080;">&#41;</span>
&nbsp;
shinyUI<span style="color: #080;">&#40;</span>pageWithSidebar<span style="color: #080;">&#40;</span>
&nbsp;
  <span style="color: #228B22;"># Application title</span>
  headerPanel<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;tkdensity&quot;</span><span style="color: #080;">&#41;</span>,
&nbsp;
  <span style="color: #228B22;"># Sidebar with a slider input for number of observations</span>
  sidebarPanel<span style="color: #080;">&#40;</span>
               selectInput<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;distribution&quot;</span>, <span style="color: #ff0000;">&quot;Distribution:&quot;</span>, 
                           choices <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Normal&quot;</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;rnorm&quot;</span>, <span style="color: #ff0000;">&quot;Exponential&quot;</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;rexp&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,
               selectInput<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;kernel&quot;</span>, <span style="color: #ff0000;">&quot;Kernel:&quot;</span>, 
                           choices <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;gaussian&quot;</span>, <span style="color: #ff0000;">&quot;epanechnikov&quot;</span>, <span style="color: #ff0000;">&quot;rectangular&quot;</span>,
                             <span style="color: #ff0000;">&quot;triangular&quot;</span>, <span style="color: #ff0000;">&quot;cosine&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,
               selectInput<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;size&quot;</span>, <span style="color: #ff0000;">&quot;Size:&quot;</span>, 
                           choices <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">c</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">5</span>,<span style="color: #ff0000;">50</span>, <span style="color: #ff0000;">100</span>, <span style="color: #ff0000;">200</span>, <span style="color: #ff0000;">300</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,
               sliderInput<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;bandwidth&quot;</span>, <span style="color: #ff0000;">&quot;bandwidth:&quot;</span>, 
                           <span style="color: #0000FF; font-weight: bold;">min</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">0.05</span>, 
                           <span style="color: #0000FF; font-weight: bold;">max</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">2</span>, 
                           value <span style="color: #080;">=</span> <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
  <span style="color: #080;">&#41;</span>,
&nbsp;
  <span style="color: #228B22;"># Show a plot of the generated distribution</span>
  mainPanel<span style="color: #080;">&#40;</span>
    plotOutput<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;distPlot&quot;</span><span style="color: #080;">&#41;</span>
  <span style="color: #080;">&#41;</span>
<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>There are a few containers (“panels”) and a few controls specified (“inputs”). The basic usage of <em>shiny</em> involves just a handful of each and they are easy to learn. The above code simply makes a header, puts four controls into a side panel and in the main panel readies a place to display our plots. The name <em>distPlot</em> is odd because I stole this basic set up from one of <em>shiny</em>&#8216;s examples and made just minor changes.</p>
<p>The <em>server.R</em> file is not difficult either. We need to make the graphic so that it displays. Here it is:</p>

<div class="wp_codebox"><table><tr id="p6079953"><td class="code" id="p60799code53"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">library</span><span style="color: #080;">&#40;</span>shiny<span style="color: #080;">&#41;</span>
&nbsp;
shinyServer<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>input, output<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
&nbsp;
  make_plot <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span>distribution, size, bandwidth, <span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    y <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">get</span><span style="color: #080;">&#40;</span>distribution<span style="color: #080;">&#41;</span><span style="color: #080;">&#40;</span>size<span style="color: #080;">&#41;</span>
    <span style="color: #0000FF; font-weight: bold;">plot</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">density</span><span style="color: #080;">&#40;</span>y, bw<span style="color: #080;">=</span>bandwidth, <span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">kernel</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
    <span style="color: #0000FF; font-weight: bold;">points</span><span style="color: #080;">&#40;</span>y, <span style="color: #0000FF; font-weight: bold;">rep</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0</span>, size<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
  <span style="color: #080;">&#125;</span>
&nbsp;
  output$distPlot <span style="color: #080;">&lt;-</span> reactivePlot<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">function</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
    make_plot<span style="color: #080;">&#40;</span>input$distribution, input$size, input$bandwidth, input$kernel<span style="color: #080;">&#41;</span>
  <span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Again, this is only slightly modified from an example. The <em>input</em> object is not a list or an environment, but we can extract the values associated with the user interface as though it were. In the above we see the <em>distribution</em>, <em>size</em>, <em>bandwidth</em> and <em>kernel</em> values are passed along to the <em>make_plot</em> call. The only new thing here, besides that, is the magic way we create a plot (passing a function as a call back to <em>reactivePlot</em> and assigning it to <em>distPlot</em> in the <em>output</em> object). The <em>shiny</em> package takes care of the third part of our GUI, using this “reactive” programming style to synchronize various parts of<br />
the interface.</p>
<p>Want to see it at work? Well fire up your copy of <em>shiny</em> and run it from a GitHub gist:</p>

<div class="wp_codebox"><table><tr id="p6079954"><td class="code" id="p60799code54"><pre class="rsplus" style="font-family:monospace;"><span style="color: #0000FF; font-weight: bold;">require</span><span style="color: #080;">&#40;</span>shiny<span style="color: #080;">&#41;</span>
shiny<span style="color: #080;">:::</span><span style="">runGist</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;4009017&quot;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>Before you gloss over the above lines, think how neat this is. Just as you can install packages from GitHub within an R session through the <em>devtools</em> package, you can run <em>shiny</em> apps within R from GitHub with the <em>runGist</em> function. This is an awesome feature for deploying interactive web apps for local usage.</p>
<p>I think you&#8217;ll see, if you compare, for this task the user experience is nicer with <em>shiny</em> than that of <em>gWidgetsWWW2.rapache</em>. The specification of the GUI is easiest with the <em>manipulate</em> style, but using <em>shiny</em> wasn&#8217;t difficult. I personally like very much the use of the “bootstrap” CSS libraries (<a href="http://twitter.github.com/bootstrap/" target="_blank">http://twitter.github.com/<wbr>bootstrap/</wbr></a>), as opposed to the ExtJS CSS (<a href="http://www.sencha.com/products/extjs/" target="_blank">http://www.sencha.com/<wbr>products/extjs/</wbr></a>). The interface looks very modern. (Not only looks, the slider is much better than that in <em>gWidgetsWWW2.rapache</em>, where the underlying control only wants integer values.) Though the <em>gWidgetsWWW2.rapache</em> package might have more controls and more layout options than the basic use of <em>shiny</em>, I can see that there will be a huge number of great <em>shiny</em> apps written. Within its range of use, it is a great choice for easily making R-driven web applications.</p>
<h2>About:</h2>
<p>John Verzani is the maintainer of the <em>gWidgets</em> set of packages and co-author with Michael Lawrence of the book <em>Programming Graphical User Interfaces in R</em>.</p>
<div class='wpfblike' style='height: 60px;'><fb:like href='http://www.r-statistics.com/2012/11/comparing-shiny-with-gwidgetswww2-rapache/' layout='default' show_faces='true' width='400' action='like' colorscheme='light' send='false' /></div>]]></content:encoded>
			<wfw:commentRss>http://www.r-statistics.com/2012/11/comparing-shiny-with-gwidgetswww2-rapache/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 4.940 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-05-23 15:23:51 -->

<!-- Compression = gzip -->