Monthly Archives: September 2011

R to Word, revisited

September 12, 2011
By

In a previous post (a long time ago) I discussed a way to get a R data frame into a Word table. The code in that entry was essentially a brute force way of wrapping R data in RTF code, but that RTF code was the bare minimum. There was no optimization of widths, or borders, or...

Read more »

Converting values to color levels

September 12, 2011
By
Converting values to color levels

     Adding color to a plot is helpful in many situations for visualizing an additional dimension of the data. Again, I wrote the below function "val2col" in R after having coded this manually over and over in the past. It uses similar arguments as the image function in that one defines the...

Read more »

Solve your R problems

September 12, 2011
By
Solve your R problems

  download ‘The R Inferno’ Epilogue I’m not a lawyer, but here is my understanding of the rules should you want to extract images from this page: Most of the images are from istockphoto.com. You would need to pay for each image that you want to use. It is unlikely that Sandro Botticelli is going … Continue reading...

Read more »

Call by reference in R

September 11, 2011
By
Call by reference in R

Sometimes it is convenient to use “call by reference evaluation” inside an R function. For example, if you want to have multiple return value for your function, then either you return a list of return value and split them afterward or you can return the value via the argument. For some reasons(I would like to

Read more »

LondonR, 7 September 2011

September 11, 2011
By
LondonR, 7 September 2011

On 7 September 2011 I attended the London R user group meeting. It was a very good turn out with about 50 attendees at the Shooting Star, a pub close to Liverpool Street Station. The session started at 18:00 with four presentations, followed by drinks ...

Read more »

Including googleVis output into a blogger post

September 11, 2011
By
Including googleVis output into a blogger post

It seems that you cannot include Google Visualisation Charts into a blog post directly.So, I tried to include the output of a googleVis function as a gadget, but also unsuccessful.Although you can include gadgets into your site template, it doesn't see...

Read more »

R subplot() with multiple lines

September 11, 2011
By

I have recently used the subplot() function of the TeachingDemos library for R: I wanted to create a simple embedded chart with multiple lines on it. The trick was to create a simple function that prepares the whole plot and pass it to the subplot() function to execute as shown below: > x > x() > plot(1:10)...

Read more »

Alternately coloured line environment with fancyvrb

September 11, 2011
By

Recently, while typing up an R tutorial, I used the LaTeX fancyvrb package to create two environments—one coloured blue for R commands, and one coloured red to display R output. This worked well for large blocks of each type. Then I decided I wan...

Read more »

A shortcut function for install.packages() and library()

September 10, 2011
By
A shortcut function for install.packages() and library()

I enjoy trying difference kind of R packages. Since I have more than 1 computers (1 at home, 1 at office and a laptop) it is troublesome to check whether I have installed some new packages for each computer. Therefore i wrote a function to load and install packages at once. If the package does

Read more »

Visualizing Bayesian Updating

September 10, 2011
By
Visualizing Bayesian Updating

One of the most straightforward examples of how we use Bayes to update our beliefs as we acquire more information can be seen with a simple Bernoulli process. That is, a process which has only two  possible outcomes. Probably the most commonly thought of example is that of a coin toss. The outcome of tossing

Read more »