Blog Archives

R Environments for Gibbs Sampler State

August 10, 2010
By
R Environments for Gibbs Sampler State

I recently decided to revisit some R code that implements a Gibbs sampler in an attempt to decrease the iteration time. My strategy was to implement the sampler state as an R environment rather than a list. The rationale was that passing an environment to and from functions would reduce the amount of duplication (memory

Read more »

Extension to an R Package: brew gets a weave

July 28, 2010
By

I’ve had enough of copy and pasting output from my R session into my email editor, blog, etc. I need something like Sweave for plain text files. In particular, I want the result of parsing <<echo=TRUE>>= f <- function(x) { x + 1 } f(1) @ with Sweave, but without the latex markup. For example,

Read more »

A tty Connection for R

July 26, 2010
By

I completed (some time ago) an initial version of a patch for R, version 2.11.1, that adds a POSIX tty connection. The patch is confirmed to compile and works on Mac OS X (thanks to Ashwin Bhat of Georgia Tech) and Debian GNU Linux. However, it should be portable to other POSIX compliant operating systems.

Read more »

Documenting R‘s Connections Internals

July 16, 2010
By
Documenting R‘s Connections Internals

In studying R‘s connections source code, I’ve put together a series of notes about their workings. Rather than let the notes go where most of my notes go (I have no idea ), I decided to do some proofreading and make the notes available to others who might be interested. These notes should make the

Read more »

Short Open Source Q&A with Revolution Analytics

July 14, 2010
By

I recently e-mailed David Smith of Revolution Analytics with a few questions about their relationship with the R-project, and how they handle R‘s source code. David mentioned, and I’m flattered that my email motivated an additional page on the Revolution website. Beyond this, I have no other relationship with the company. I’d like to thank

Read more »

Funny Math in Governor Approval Ratings

July 9, 2010
By

Andrew Gelman wrote today about some erroneous U.S. Governor approval ratings, noting that the ratings for Janet Napolitano sum to 108%. In fact most of these ratings do not sum to 100%. I prepared a clean CSV file of the ratings, making use of R‘s XML library and the readHTMLTable function. The ratings data file

Read more »

ASCII Scatterplots in R

June 25, 2010
By
ASCII Scatterplots in R

I really like R‘s stem function, it creates a stem-and-leaf plot right in the R console, no fancy graphics devices required! In a recent R-help post, Ralf Bierig presented a very nice ASCII scatterplot representing two densities. Unfortunately, I don’t know of any R function that will generate this type of plot, but I will

Read more »

More powerful iconv in R

June 19, 2010
By

The R function iconv converts between character string encodings, for example, from the locale dependent encoding to UTF-8: > iconv("foo", to="UTF-8") [1] "foo" However, R has long-running trouble with embedded null characters ('') in strings. Hence, if we try to convert to an encoding that permits embedded null characters, iconv will fail: > iconv("foo", to="UTF-16")

Read more »

Mary, Chloe, and Miriam at breakfast

June 16, 2010
By
Mary, Chloe, and Miriam at breakfast

Read more »

R-help follow-up: truncated exponential

June 16, 2010
By
R-help follow-up: truncated exponential

I recently posted the message below with regard to sampling from the truncated exponential distribution. I left out the derivation of the CDF (mostly because text math is ugly), so I’ve included it here. There is also a short JSS article about truncated distributions in R. This problem in particular may likely be found in

Read more »