<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: r code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 22 May 2008 12:22:06 GMT</pubDate>
    <description>DZone Snippets: r code</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>clear workspace</title>
      <link>http://snippets.dzone.com/posts/show/1982</link>
      <description>clean up R workspace&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;rm(list = ls(all = TRUE))&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 05 May 2006 09:56:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1982</guid>
      <author>rcs ()</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>
    <item>
      <title>Read CSV and plot</title>
      <link>http://snippets.dzone.com/posts/show/783</link>
      <description>&lt;br /&gt;&lt;code&gt;&lt;br /&gt; oaks &lt;- read.table("assign1/oaksdf.csv",sep=",")&lt;br /&gt; oakpts &lt;- as.points(oaks[,1],oaks[,2])&lt;br /&gt; plot(oakpts)&lt;br /&gt;&lt;code&gt;</description>
      <pubDate>Tue, 04 Oct 2005 06:41:53 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/783</guid>
      <author>dandye (Dan Dye)</author>
    </item>
    <item>
      <title>create rotated axis labels</title>
      <link>http://snippets.dzone.com/posts/show/472</link>
      <description>The R FAQ states:&lt;br /&gt; &lt;br /&gt;&lt;code&gt;&lt;br /&gt;par(mar = c(7, 4, 4, 2) + 0.1)&lt;br /&gt;plot(1 : 30, xaxt = "n",  xlab = "")&lt;br /&gt;labels &lt;- paste("Label", 1:30, sep = " ")&lt;br /&gt;text(1:30, par("usr")[3] - 0.25, srt = 90, adj = 1,labels = labels, xpd = TRUE)&lt;br /&gt;mtext(1, text = "X Axis Label", line = 6)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Also see Figure 1 and associated code in Paul Murrell (2003), &#226;&#8364;&#339;Integrating grid Graphics Output with Base Graphics Output&#226;&#8364;?, R News, 3/2, 7&#226;&#8364;&#8220;12.</description>
      <pubDate>Sat, 09 Jul 2005 01:17:23 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/472</guid>
      <author>r-fanatic ()</author>
    </item>
  </channel>
</rss>
