Articles by Ari F.

Apply-style commands in R

March 14, 2013 | Ari F.

Here's a quick table of what I think are the most useful apply-style commands in R: FunctionInputOutputBest forapplyRectangularRectangular or vectorApplying function to rows or columnslapplyAnythingListNon-trivial operations on almost any data typesap... [Read more...]

R scripts for analyzing survey data

February 2, 2013 | Ari F.

Another site pops up with open code for analyzing public survey data: http://www.asdfree.com/ It will be interesting to see whether this gets used by the general public--given the growing trend of data journalism and so forth--versus academics. It is... [Read more...]

This is *huge*: SAScii package

July 10, 2012 | Ari F.

http://blog.revolutionanalytics.com/2012/07/importing-public-data-with-sas-instructions-into-r.html Q: How do you make a hairless primate? Answer 1: Take a hairy primate, wait a few million years and see if Darwin was right. Answer 2: Make them work i... [Read more...]

Dates and times in R

March 16, 2012 | Ari F.

Nothing looks funnier than a patchy simian. That's why we sighed a great sigh of relief when we spotted this article on the lubridate package in R. It saves a great deal of hair pulling.http://www.r-statistics.com/2012/03/do-more-with-dates-and-times... [Read more...]

Reading huge files into R

February 19, 2012 | Ari F.

SAS is much touted for its ability to read in huge datasets, and rightly so. However, that ability comes at a cost: for smaller datasets, since files remain on the disk rather than in memory (as is the case with Stata and R), it is potentially less fa... [Read more...]

We are now a part of R-bloggers.com

June 9, 2011 | Ari F.

R-bloggers is a site that aggregates many of the best R blogs on the internet. We're glad they've allowed our R-related posts to be aggregated there. If you mainly write in R, it's worth checking them out. [Read more...]

R: Speeding things up

June 9, 2011 | Ari F.

R is many things, but it's not exactly speedy like a Patas Monkey. In fact, while it is much faster than many other solutions, R is notably slower than Stata (even inspiring talks that it should be rewritten from scratch!).Fortunately, Radford Neal ha... [Read more...]

R: Drop factor levels in a dataset

March 9, 2011 | Ari F.

R has factors, which are very cool (and somewhat analogous to labeled levels in Stata). Unfortunately, the factor list sticks around even if you remove some data such that no examples of a particular level still exist# Create some fake datax levels(x)x levels(x) # still the same levelstable(... [Read more...]

R: Functions and environments and a debugging utility, oh my!

February 7, 2011 | Ari F.

The Mark Fredrickson blog has a superb post on R functions and environments that's well worth checking out.He also includes a handy function for debugging:__ fnpeek + env + if (is.null(name)) {+ return(ls(envir = env))+ }+ if (name %in% ls(envir = env)) {+ return(get(name, env))+ }+ return(NULL)+ }__ fnpeek(f1)[1] "... [Read more...]

R: Colors

February 4, 2011 | Ari F.

"It ain't easy being green. ~ Kermit T. F. Matt Blackwell at the SSSB has made it easy to access all the Craylola(tm) colors in R.And in case you're not familiar with the way R handles color, here are a few resources:* The best color chart for R.* Colo... [Read more...]

Regular expressions, an example

February 3, 2011 | Ari F.

Why regular expressions are your friend. This is written in Stata but applies to any language where regular expressions exist.Original version if length("`qx'")==3 { /*ex: 5q0*/ local a = substr("`qx'", 1, 1) local b = substr("`qx'", 3, 1) } else if substr("`qx'", 2, 1) == "q" & length("`qx'")==4 { /*ex: 5q20*/ local a = substr("`qx'", 1, 1) local b = ... [Read more...]

Tab completion

January 30, 2011 | Ari F.

Let's say your hands are aching from too much typing in of variables. What to do? Get a keyboard tray and learn proper ergonomics, of course.But what if you just want to reduce the amount of typing in of variables you do for reasons of laziness...err... [Read more...]

STATA: Regular expressions

January 23, 2011 | Ari F.

A regular expression allows you to do a moderately fancy search (and replace if you want). So say you wanted to replace all the "Dennis"s in a variable with "Awesome"s, but only if they're at the end of the line. You could try:-replace PBFnamevar = r... [Read more...]

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)