segunda-feira, 21 de janeiro de 2013

El Nino and ggplot2

Some days ago i've got stucked in what appears to be a simple task: read some El Nino data, and then plot it. The problem was the data file format, which you can find here: El Nino Data.

There's a mix between 'white space' and '.' characters, so read.csv or read.table won't work. It happens this is called a fixed width format, and R has the mighty read.fwf() function to save us a lot of work. So let's put this into action together with ggplot2!

The code below shows how to use the read.fwf() function and then it's pure ggplot2 stuff. You just need to call the function: plot.nino(). Enjoy it!

3 comentários:

  1. Hi Fernando,

    I tried running your script above but not seems to appear. Is there any additional code that needs to be run to view the plots? Apologize for the not so smart question as I am very new to R.

    Thanks!

    ResponderExcluir
  2. Hello Jason,
    You need to call the function with : plot.nino().
    I've edited the post, thanks!

    ResponderExcluir