Querying Databases in R
Filed in Data Munging, R, R Tip, August 14, 2009, 9:00 amOne of the first things you’ll want to do in R is set it up to talk to databases. The easiest way to do this is using ODBC, via package RODBC.
To get the package, run
> install.packages(RODBC)
Once you have RODBC installed, you call it in R as follows. But it’s very simple: a bit [...]
MySQL, Batch Imports, and Rails
Filed in Data Munging, August 13, 2009, 6:00 amI really love Rails, but it’s not the most performant code in the world. Though it doesn’t often arise in CRUD programming, if you do any sort of stats, ML, or data analytics, you’ll frequently find yourself wanting to import lots of data into your db. You could create an ActiveRecord object for [...]
R Dates – Recovering and Converting From Integers
Filed in R, R Tip, August 12, 2009, 9:00 amOne problem with R is that dates (class Date) are internally stored as integer numbers of days elapsed since 1 January 1970 and R sometimes loses the dateness of the variables and thinks of it only as an integer. So in the first line, we take the range of dates present in our data, [...]
Shading Pieces of an R Plot
Filed in Plotting, R, Visualization, August 11, 2009, 6:25 pmThis is post #11 in a running series about plotting in R.
I often want to shade pieces of an R plot, in order to visually draw out some piece, such as weekends or recessions. Let’s look at how to do that with the plain plotting tools.
First, I have some obscured data from [...]
Matt Riley Rides the Zip Line at Scribd
Filed in Uncategorized, , 3:39 pmWe are trying to speed the zip line up so we attached what is basically a 300 foot rubber band — a tan, 4mm, Thera Band Roll to two columns and shot Matt down the zip line. He flew! Unfortunately, the latex band wasn’t as robust as we would have liked.
Here’s the video [...]
Examining Data Frames — head and tail
Filed in Data Munging, R, R Tip, August 2, 2009, 12:30 amhead and tail, for those familiar with the unix command line, are two very handy utilities for looking at data frames. Along with str, which displays the structure of a data frame, they help you look at your data:
> d d
> str(d)
‘data.frame’: 50 obs. of 2 variables:
$ mean: int 1 [...]