From 51783d28f9a4f765de6bf342a347e63ffddca065 Mon Sep 17 00:00:00 2001 From: boB Rudis Date: Thu, 25 Jan 2018 17:48:44 -0500 Subject: [PATCH] README --- README.Rmd | 26 +++++++++++++++++++++++++- README.md | 27 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/README.Rmd b/README.Rmd index 4846a94..b2c3b70 100644 --- a/README.Rmd +++ b/README.Rmd @@ -12,6 +12,8 @@ Compute Global Terminator (Day/Night) Bands Compute global terminator (day/night) bands which can be overlayed as day and night regions on a ggplot2 world map. +This is an Rcpp port of a [pure R port](https://github.com/JoGall/terminator) (by @JoGall) of a JS leaflet plugin. + ## What's Inside The Tin The following functions are implemented: @@ -31,14 +33,36 @@ options(width=120) ## Usage -```{r message=FALSE, warning=FALSE, error=FALSE, eval=TRUE} +(NOTE: If you're trying to just knit this Rmd, remove the `eval=FALSE` bits. I didn't want to keep generating things and was too impatient to wait for a `cache=TRUE` run). + +```{r message=FALSE, warning=FALSE, error=FALSE} library(terminator) library(ggplot2) library(gganimate) # devtools::install_github("dgrtwo/gganimate") # current verison packageVersion("terminator") +``` + +Joe had an asesome idea and made a perfectly fine pure R port. This one is just a wee bit faster. + +```{r bench, eval=FALSE} +microbenchmark::microbenchmark( + pure_r = pure_r_terminator(as.POSIXct(Sys.Date()) + (60*60*0), -180, 190, 0.5), + rcpp = terminator::terminator(as.POSIXct(Sys.Date()) + (60*60*0), -180, 190, 0.5), + times=100 +) -> mb + +mb +## Unit: microseconds +## expr min lq mean median uq max neval +## pure_r 178131.642 196554.32 206498.7256 204881.1060 214984.7260 339901.567 100 +## rcpp 493.219 642.67 752.3545 747.8535 828.3085 1044.269 100 +``` + +Using Joe's animation example: +```{r anim, eval=FALSE} term_seq <- terminator_lat_lon() chart <- ggplot(term_seq, aes(frame = frame)) + diff --git a/README.md b/README.md index 73d8de9..e06f2fb 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ Compute Global Terminator (Day/Night) Bands Compute global terminator (day/night) bands which can be overlayed as day and night regions on a ggplot2 world map. +This is an Rcpp port of a [pure R +port](https://github.com/JoGall/terminator) (by @JoGall) of a JS leaflet +plugin. + ## What’s Inside The Tin The following functions are implemented: @@ -23,6 +27,10 @@ devtools::install_github("hrbrmstr/terminator") ## Usage +(NOTE: If you’re trying to just knit this Rmd, remove the `eval=FALSE` +bits. I didn’t want to keep generating things and was too impatient to +wait for a `cache=TRUE` run). + ``` r library(terminator) library(ggplot2) @@ -34,6 +42,25 @@ packageVersion("terminator") ## [1] '0.1.0' +Joe had an asesome idea and made a perfectly fine pure R port. This one +is just a wee bit faster. + +``` r +microbenchmark::microbenchmark( + pure_r = pure_r_terminator(as.POSIXct(Sys.Date()) + (60*60*0), -180, 190, 0.5), + rcpp = terminator::terminator(as.POSIXct(Sys.Date()) + (60*60*0), -180, 190, 0.5), + times=100 +) -> mb + +mb +## Unit: microseconds +## expr min lq mean median uq max neval +## pure_r 178131.642 196554.32 206498.7256 204881.1060 214984.7260 339901.567 100 +## rcpp 493.219 642.67 752.3545 747.8535 828.3085 1044.269 100 +``` + +Using Joe’s animation example: + ``` r term_seq <- terminator_lat_lon()