Posts Tagged ‘ R ’

Yes, it can

August 2, 2006
By

Joel on Software’s latest post is about having first class functions in your programming language. He shows how you can use functions as arguments to functions to reduce code duplication. IReducing code duplication is a nice way to motivate languag...

Read more »

R syntax highlighting for Smultron

June 14, 2006
By
R syntax highlighting for Smultron

Smultron is an open-source text-editor for OS X. It’s a very lean editor, but it’s fast and it was written in Cocoa. Out of the box it has syntax highlighting for Stata and LaTeX, but not R. Basic instructions for adding a rudimentary R syntax coloring file are available here. However, I have adapted the

Read more »

Here’s an improved system.time function for R

May 14, 2006
By

R’s current system.time function doesn’t name the vector of return values. Doing so makes it easier to understand the output. IMO, the current code has two uglies: it sets an on.exit hook and then calls on.exit() explicitly. It also computes the elapsed time twice (once for the stdout message and once for the

Read more »

Here’s an improved system.time function for R

May 14, 2006
By

R’s current system.time function doesn’t name the vector of return values. Doing so makes it easier to understand the output. IMO, the current code has two uglies: it sets an on.exit hook and then calls on.exit() explicitly. It also computes the ...

Read more »

Aggregating Results from Unreliable Functions in R

May 12, 2006
By

I posted this as a response to a question on R-help. I think the idea of a “collect” function could be useful both in the context of unreliable functions that sometimes error out and also in filtering contexts where currently one creates a list containing good elements and some sort of sentinel, usually NULL,

Read more »

Aggregating Results from Unreliable Functions in R

May 12, 2006
By

I posted this as a response to a question on R-help. I think the idea of a “collect” function could be useful both in the context of unreliable functions that sometimes error out and also in filtering contexts where currently one creates a list co...

Read more »

Merging data: A tutorial

May 7, 2006
By
Merging data: A tutorial

The situation: you have two datasets with a common variable, and you want to incorporate both into one large dataset containing all of the variables. This is called merging data, and it’s easy to do in any standard statistical package. In these examples, I assume that there is only one variable between any datasets to

Read more »

R Language Module for TextWrangler (and a lot of other editors)

February 27, 2006
By
R Language Module for TextWrangler (and a lot of other editors)

Via this page, I just learned that there is a TextWrangler Language Module for R. The file itself is available here. To install, copy the .plist file to the following directory Username/Library/Application Support/TextWrangler/Language Modules I also recommend going into TextWrangler’s preferences and changing the color for comments. The default is a gray color that doesn’t

Read more »

Basic factor analysis in R

February 17, 2006
By
Basic factor analysis in R

The call to perform factor analysis on a set of variables in R is: fact1<- factanal(x,factors,scores=c(“regression”),rotation=”varimax”) where “x” is a dataframe containing the appropriate variables, and “factors” is the number of factors to be extracted. socres=”…” and rotation=”…” are optional, and varimax is the default rotation. The factanal function doesn’t seem to handle missing observations

Read more »

Getting tables from R output

February 11, 2006
By
Getting tables from R output

Turning plain-text output into well-formatted tables can be a repetitive task, especially when many tests or models are being incorporated into a paper. For R users, there are several methods that can make this task easier (though not much less repetitive), regardless of what typesetting system you use. LaTeX tables The xtable package produces LaTeX-formatted

Read more »