Basic R Studio and ggplot2 syntax

While I continue to try to get Sage to underpin the analysis stages of my open scientific workflow, a LOT of my colleagues and cohort use R these days.  So this week I installed R Studio and ggplot2 for OSX.

Here are notes from my first foray into plotting histograms.

First I took some date/time data in a Libre Office spreadsheet, converted it to decimal hour of day to keep things simple, renamed column headers to be simple single words (e.g. underscores to connect words), and then saved the active sheet as a tab-delimited .csv file (in this case named 2012-human.csv).

> lk2012<-read.table("/Users/scott/Documents/beamreach/research/pubs-in-progress/02a - ship SL/r-scott/2012-human.csv",header=T,sep="\t")
> png("/Users/scott/Documents/beamreach/research/pubs-in-progress/02a - ship SL/r-scott/lk-human-hr-hists.png")
> par(mfrow= c(3, 1))
> hist(lk2011$hour,breaks=24) > hist(lk2012$hour,breaks=24)
> hist(lk2013\$hour,breaks=24)
> dev.off()


That reads the .csv file into lk2012, then prints this 3 panel plot of hour histograms —

Histograms of the hours in which reports were made to the Salish Sea hydrophone network’s Google-spreadsheet-based observation log in 2011, 2012, & 2013.

More on ggplot2 as I learn it… but know that it is making most of the plots for our current paper in progress regarding underwater noise from Salish Sea ships.