Parsing and plotting time series data

January 15, 2011
By

(This article was first published on Why? » R, and kindly contributed to R-bloggers)

This morning I came across a post which discusses the differences between scala, ruby and python when trying to analyse time series data. Essentially, there is a text file consisting of times in the format HH:MM and we want to get an idea of its distribution. Tom discusses how this would be a bit clunky in ruby and gives a solution in scala.

However, I think the data is just crying out to be “analysed” in R:

require(ggplot2)#Load the plotting package
times = c("17:05", "16:53", "16:29", ...)#would be loaded from a file
times = as.POSIXct(strptime(times, "%H:%M")) #convert to POSIXct format
qplot(times, fill=I('steelblue'), col=I('black'))#Plot with nice colours

Which gives

I definitely don’t want to get into any religious wars of R vs XYZ. I just wanted to point out that when analysing data, R does a really good job.

 

 


To leave a comment for the author, please follow the link and comment on his blog: Why? » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , ,

Comments are closed.