Created
June 21, 2012 00:44
-
-
Save dholstius/2963186 to your computer and use it in GitHub Desktop.
Extended historical queries with the cosm R package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('cosm') | |
if (!exists('key')) key <- readline('API key: ') | |
feed <- getFeed(58537, key) | |
print(feed$description) | |
t0 <- Sys.time() | |
duration <- 60 * 60 * 24 * 7 # one week | |
z <- getDatapoints(feed, key, datastreams='2h', end=t0, start=t0-duration) | |
while (TRUE) { | |
t0 <- t0 - duration | |
message("Requesting: end = ", t0) | |
result <- getDatapoints(feed, key, datastreams='2h', end=t0, start=t0-duration) | |
if (is.null(result)) break | |
z <- c(z, result) | |
} | |
plot(z, main=feed$title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment