Category Archives: R

R Dates – Recovering and Converting From Integers

One 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 … Continue reading

Posted in R, R Tip | Tagged | Leave a comment

Shading Pieces of an R Plot

This 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 … Continue reading

Posted in Plotting, R, Visualization | Tagged , | Leave a comment

Examining Data Frames — head and tail

head 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: > … Continue reading

Posted in Data Munging, R, R Tip | Tagged | Leave a comment

Filled Line Plots / Graphs in R — Part 10 in a Series

This is post #10 in a running series about plotting in R. Otherwise known as filled curves. Say you want to, instead of drawing a single line, draw a filled curve. R’s basic plot doesn’t make the especially easy, though … Continue reading

Posted in Plotting, R, Visualization | 1 Comment

Multiple Y Axes in R Plots — Part 9 in a Series

This is post #09 in a running series about plotting in R. Frequently, you want to plot data that is not at all on the same scale. In R, this is done via plotting a second graph on top of … Continue reading

Posted in Plotting, R, Visualization | Tagged , | 2 Comments

Visualizing and Comparing Distributions — Part 8 of a Series

This is post #08 in a running series about plotting in R. Last time, I talked about visualizing the Uniform, Normal, Exponential, and Poisson Distributions. However, there are more useful methods than just plotting the density and distribution functions. Of … Continue reading

Posted in Plotting, R, Statistics, Visualization | Tagged , | Leave a comment

Multiple Plots and Visualizing Distributions – Part 7 in a Series

This is post #07 in a running series about plotting in R. I was helping a friend plot some interesting distributions this weekend, so I decided to use distributions to demonstrate one of the neater bits of R’s basic plotting … Continue reading

Posted in Plotting, R, Statistics, Visualization | Tagged , | 1 Comment

Removing Extra Column of Data from CSVs in R — R Tip

When R writes a csv file, you get an extra column of data as such: > s > plot(x=s$x, y=s$y ) > > write.csv(x=s, file=’s0.csv’ ) When you peek in the csv file, you see this: blog earl$ head s0.csv … Continue reading

Posted in Data Munging, R, R Tip | Tagged , | Leave a comment

Examining CSV Data Columns From a Shell

It’s very handy to be able to pop open a shell and peek in your csv files. awk is a command that will do just that — it divides each line into fields based either on a whitespace separator or … Continue reading

Posted in Data Munging, R, R Tip | Tagged | Leave a comment

Labeling Plots – Annotations, Legends, etc — Part 6 in a Series

This is post #06 in a running series about plotting in R. You regularly want to label pieces of a plot in order to point a particular feature out or answer a question that your audience will have. Let’s see … Continue reading

Posted in Plotting, R, Visualization | Tagged , | Leave a comment