Here we go, an R package with a couple of helpful functions to help you pull your data from the Cosm API:
- feed_detail() returns JSON-like data as nested lists.
- feed_history() returns a zoo object representing selected datastreams.
Why zoo objects? Well, zoo is one of the most widely relied-on R packages. It’s a building block, much like the sp package for spatial data. If you’re working with totally ordered observations—like repeated measurements from one sensor or device—then it seems likely that you’ll encounter it sooner or later. (The zoo FAQ and the Time Series R task view explain more about related packages.) R’s “baked-in” ts objects and methods are designed for regular time series, and let’s face it, when you’re logging sensor measurements from a microcontroller, there’s no way your measurements are exactly equally spaced. But they are totally ordered.
Here’s a quick example of what your R code might look like using this package:
If you want to install it and play around, I suggest first installing Hadley Wickham’s excellent devtools package. Then you can just install directly from my GitHub repository, like so: