<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Mroutley's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 01:41:37 GMT</pubDate>
    <description>DZone Snippets: Mroutley's Code Snippets</description>
    <item>
      <title>Create data frame from variable number of vectors</title>
      <link>http://snippets.dzone.com/posts/show/3842</link>
      <description>// Create a data frame from a varied number of vectors&lt;br /&gt;// Taken from http://article.gmane.org/gmane.comp.lang.r.general/56501/match=create+data+frame&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;N1 &lt;-c(1,2,3,4)&lt;br /&gt;N2 &lt;-c(1,2,3,4)&lt;br /&gt;N3 &lt;-c(1,2,3,4)&lt;br /&gt;abc &lt;-c(1,2,3)&lt;br /&gt;lab &lt;- paste("N", seq(along=abc), sep="")&lt;br /&gt;D &lt;- data.frame(lapply(lab, get))&lt;br /&gt;names(D) &lt;- lab&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 19 Apr 2007 20:08:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3842</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Call Growl from R</title>
      <link>http://snippets.dzone.com/posts/show/2638</link>
      <description>// Send an alert to growl with the R.app icon.&lt;br /&gt;// Useful for indicating the end of a long simulation.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;system(paste("growlnotify -a R -t \"Message\" -m", message, sep=""))&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Sep 2006 02:54:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2638</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Run R from the command line</title>
      <link>http://snippets.dzone.com/posts/show/2637</link>
      <description>// This runs R from the command line in batch mode.&lt;br /&gt;// The log file is output to track R's progress&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;R CMD BATCH --vanilla path/to/file.R file.log &amp;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Sep 2006 02:52:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2637</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Iteratively create objects</title>
      <link>http://snippets.dzone.com/posts/show/2181</link>
      <description>// Iteratively create objects from a list of names.&lt;br /&gt;// Especially useful for creating consistent model objects for a list of data sources.&lt;br /&gt;// Wrapping the assign statement in a try block is often advisable.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;for(item in itemList){&lt;br /&gt;	assign(paste(item, "object", sep="."),  function(get(paste(item, "data", sep=".")), options)&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 13 Jun 2006 19:51:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2181</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Position-based substitution in arrays</title>
      <link>http://snippets.dzone.com/posts/show/1949</link>
      <description>// Replace array values based on their row and column position&lt;br /&gt;// This is an alternative to using for loops to test each position&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;a &lt;- array(0, dim=c(10, 10))&lt;br /&gt;a[row(a) &lt;= col(a)*2] &lt;- 1&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 21 Apr 2006 23:59:43 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1949</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Zero-inflated negative binomial</title>
      <link>http://snippets.dzone.com/posts/show/1881</link>
      <description>// Simulates a zero-inflated, negative binomial&lt;br /&gt;// from Ben Bolker&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;rzinbinom &lt;- function(n, mu, size, zprob) {&lt;br /&gt;  ifelse(runif(n) &lt; zprob, 0, rnbinom(n, mu=mu, size=size))&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 10 Apr 2006 22:51:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1881</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Spotlight queries of R documentation</title>
      <link>http://snippets.dzone.com/posts/show/1880</link>
      <description>// from http://comments.gmane.org/gmane.comp.lang.r.mac/642&lt;br /&gt;// Use Spotlight to query R documentation&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;spotlight&lt;-function(word) {&lt;br /&gt;place&lt;-paste(Sys.getenv("R_HOME"),"/library/",sep="")&lt;br /&gt;string&lt;-paste("mdfind -onlyin",place,word,"|",getOption("pager"))&lt;br /&gt;system(string, intern=TRUE)&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 10 Apr 2006 21:45:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1880</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
  </channel>
</rss>
