Jun 042014

If you saw Hilary Parker‘s awesome post Sunsets in Google Calendar using R and got all excited about it, but have no idea how to use R, fear not. This post will help you go the distance!

First, install R. I myself use MacPorts

Susnset statue of Liberty

Susnset statue of Liberty (Photo credit: Adorenomis)

, so I did:

$ sudo port install R

which took a while and had a lot of dependencies, but whatevs, it eventually worked…

Next, save Hilary’s createsunsetcal.R file somewhere on your computer.

Open that up and modify it to use your own sunset location and lat/lon coordinates (I used Google Maps and looked at the lat/lon coordinates in the URL to fill in the data I wanted). Save it.

Now, in that same folder, open an R prompt like so and do the following:

$ R

> install.packages(“StreamMetabolism”)

… (follow the prompts here, choose a mirror, etc.)

> library(StreamMetabolism)

> source(“/path/to/downloaded/file/createsunsetcal.R”)

> createsunsetcal()

then <control> + d to exit your R session.

Congrats, you should now see a file called sunset.csv, hooray!

Thanks for the awesome write-up Hilary.

Enhanced by Zemanta