Skip to content

Commit

Permalink
2.0.1 fixed minor issues found with --as-cran check
Browse files Browse the repository at this point in the history
  • Loading branch information
hrbrmstr committed Jun 14, 2015
1 parent b15be02 commit 518621c
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 55 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rforecastio
Type: Package
Title: An R Client for the 'Forecast' API
Version: 2.0.0
Version: 2.0.1
Date: 2015-06-14
Authors@R: c(person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")))
Maintainer: Bob Rudis <bob@rudis.net>
Expand All @@ -12,7 +12,6 @@ Suggests:
testthat
Imports:
httr,
stringr,
dplyr,
grid,
gridExtra
Expand Down
13 changes: 3 additions & 10 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ export(forecastio_api_key)
export(get_current_forecast)
export(get_forecast_for)
import(dplyr)
import(ggplot2)
import(grid)
import(gridExtra)
import(httr)
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggplotGrob)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,theme_bw)
importFrom(gridExtra,grid.arrange)
3 changes: 3 additions & 0 deletions R/Rforecastio-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
#' @author Bob Rudis (@@hrbrmstr)
#' @import dplyr
#' @import httr
#' @import grid
#' @import gridExtra
#' @import ggplot2
NULL
5 changes: 2 additions & 3 deletions R/Rforecastio.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Get or set FORECASTIO_API_KEY value
#'
#' The API wrapper functions in this package all rely on a ForecastIO API
Expand All @@ -9,7 +8,7 @@
#' @param force force setting a new ForecastIO API key for the current environment?
#' @return atomic character vector containing the ForecastIO API key
#' @export
forecastio_api_key <- function(force = FALSE, time.formatter=as.POSIXct, ...) {
forecastio_api_key <- function(force = FALSE) {

env <- Sys.getenv('FORECASTIO_API_KEY')
if (!identical(env, "") && !force) return(env)
Expand Down Expand Up @@ -179,7 +178,7 @@ get_current_forecast <- function(latitude, longitude,
#' @export
#' @note You must have \code{FORECASTIO_API_KEY} in you \code{.Renvion} file for this to work
#' @examples
#' tmp <- get_current_forecast_for(37.8267,-122.423, "2013-05-06T12:00:00-0400")
#' tmp <- get_forecast_for(37.8267,-122.423, "2013-05-06T12:00:00-0400")
get_forecast_for <- function(latitude, longitude, timestamp,
units="us", language="en", exclude=NULL) {

Expand Down
44 changes: 23 additions & 21 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
#' Plot method for rforecastio objects:
# silly CRAN

temperature <- humidity <- precipIntensity <- temperatureMinTime <-
temperatureMin <- temperatureMaxTime <- temperatureMax <- NULL

#' Plot method for rforecastio xs:
#'
#' Uses ggplot2 & grid.arrange to produce graphs for rforecastio objects
#' Uses ggplot2 & grid.arrange to produce graphs for rforecastio xs
#'
#' @param object an rforecastio object
#' @param x an rforecastio x
#' @param \dots ignored
#' @param readings specify which readings to plot. will plot all available by default
#' @return frame grob
#'
#' @importFrom ggplot2 autoplot ggplot aes_string geom_line labs
#' @importFrom ggplot2 theme_bw ggplotGrob aes scale_color_manual
#' @importFrom gridExtra grid.arrange
#' @export
#' @method plot rforecastio
plot.rforecastio <- function(object, ...,
plot.rforecastio <- function(x, ...,
readings=c("hourly", "minutely", "daily")) {


lapply(readings[readings %in% names(object)], function(x) {
lapply(readings[readings %in% names(x)], function(rdng) {

gg <- ggplot()

if (x == "hourly") {
gg <- gg + geom_line(data=object[[x]], aes(x=time, y=temperature, color="Temperature"))
gg <- gg + geom_line(data=object[[x]], aes(x=time, y=humidity*10, color="Humidity"))
if (rdng == "hourly") {
gg <- gg + geom_line(data=x[[rdng]], aes(x=time, y=temperature, color="Temperature"))
gg <- gg + geom_line(data=x[[rdng]], aes(x=time, y=humidity*10, color="Humidity"))
gg <- gg + scale_color_manual(name="Readings", values=c("green", "red"))

}

if (x == "minutely") {
gg <- gg + geom_line(data=object[[x]], aes(x=time, y=precipIntensity, color="Precipitation\nIntensity"))
if (rdng == "minutely") {
gg <- gg + geom_line(data=x[[rdng]], aes(x=time, y=precipIntensity, color="Precipitation\nIntensity"))
gg <- gg + scale_color_manual(name="Readings", values=c("blue"))
}

if (x == "daily") {
gg <- gg + geom_line(data=object[[x]], aes(x=temperatureMinTime, y=temperatureMin, color="Temp (min)"), linetype=2)
gg <- gg + geom_line(data=object[[x]], aes(x=temperatureMaxTime, y=temperatureMax, color="Temp (max)"))
gg <- gg + geom_line(data=object[[x]], aes(x=time, y=humidity*100, color="Humidity"))
if (rdng == "daily") {
gg <- gg + geom_line(data=x[[rdng]], aes(x=temperatureMinTime, y=temperatureMin, color="Temp (min)"), linetype=2)
gg <- gg + geom_line(data=x[[rdng]], aes(x=temperatureMaxTime, y=temperatureMax, color="Temp (max)"))
gg <- gg + geom_line(data=x[[rdng]], aes(x=time, y=humidity*100, color="Humidity"))
gg <- gg + scale_color_manual(name="Readings", values=c("green", "red", "red"))
}

gg <- gg + labs(x=NULL, y=NULL, title=sprintf("%s readings", x))
gg <- gg + labs(x=NULL, y=NULL, title=sprintf("%s readings", rdng))
gg <- gg + theme_bw()

gg

}) -> plots
}) -> the_plots

do.call(grid.arrange, c(plots, ncol=1))
do.call(grid.arrange, c(the_plots, ncol=1))

}
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ regular data frames but get all the `dplyr` goodness, too).
### News

- Version 2.0.0 released - complete overhaul of the package
- Version 2.0.1 released - Did a check `--as-cran` and fixed _many_ things invisible to the users of this package

### Installation

Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ There have been several major enhancements to the way this package works with th
### News

- Version 2.0.0 released - complete overhaul of the package
- Version 2.0.1 released - Did a check `--as-cran` and fixed *many* things invisible to the users of this package

### Installation

Expand All @@ -41,7 +42,7 @@ library(Rforecastio)
packageVersion("Rforecastio")
```

## [1] '2.0.0'
## [1] '2.0.1'

``` r
now <- get_current_forecast(43.2672, -70.8617)
Expand All @@ -51,16 +52,16 @@ print(now$hourly)
## Source: local data frame [49 x 16]
##
## time summary icon precipIntensity precipProbability temperature
## 1 2015-06-14 18:00:00 Clear clear-day 0 0 70.56
## 2 2015-06-14 19:00:00 Partly Cloudy partly-cloudy-day 0 0 67.76
## 3 2015-06-14 20:00:00 Partly Cloudy partly-cloudy-day 0 0 64.87
## 4 2015-06-14 21:00:00 Partly Cloudy partly-cloudy-night 0 0 62.43
## 5 2015-06-14 22:00:00 Partly Cloudy partly-cloudy-night 0 0 61.31
## 6 2015-06-14 23:00:00 Mostly Cloudy partly-cloudy-night 0 0 60.44
## 7 2015-06-15 00:00:00 Mostly Cloudy partly-cloudy-night 0 0 59.35
## 8 2015-06-15 01:00:00 Overcast cloudy 0 0 59.03
## 9 2015-06-15 02:00:00 Overcast cloudy 0 0 58.60
## 10 2015-06-15 03:00:00 Overcast cloudy 0 0 58.13
## 1 2015-06-14 19:00:00 Clear clear-day 0.0000 0.00 67.91
## 2 2015-06-14 20:00:00 Partly Cloudy partly-cloudy-day 0.0000 0.00 64.85
## 3 2015-06-14 21:00:00 Partly Cloudy partly-cloudy-night 0.0000 0.00 62.35
## 4 2015-06-14 22:00:00 Partly Cloudy partly-cloudy-night 0.0000 0.00 61.18
## 5 2015-06-14 23:00:00 Mostly Cloudy partly-cloudy-night 0.0000 0.00 60.37
## 6 2015-06-15 00:00:00 Mostly Cloudy partly-cloudy-night 0.0000 0.00 59.34
## 7 2015-06-15 01:00:00 Overcast cloudy 0.0000 0.00 59.03
## 8 2015-06-15 02:00:00 Overcast cloudy 0.0000 0.00 58.60
## 9 2015-06-15 03:00:00 Overcast cloudy 0.0000 0.00 58.13
## 10 2015-06-15 04:00:00 Overcast cloudy 0.0037 0.08 57.72
## .. ... ... ... ... ... ...
## Variables not shown: apparentTemperature (dbl), dewPoint (dbl), humidity (dbl), windSpeed (dbl), windBearing (int),
## visibility (dbl), cloudCover (dbl), pressure (dbl), ozone (dbl), precipType (chr)
Expand All @@ -83,7 +84,7 @@ print(then$daily)
print(sprintf("You have used %s API calls.", then$`x-forecast-api-calls`))
```

## [1] "You have used 33 API calls."
## [1] "You have used 70 API calls."

``` r
plot(now)
Expand All @@ -100,7 +101,7 @@ library(testthat)
date()
```

## [1] "Sun Jun 14 18:36:21 2015"
## [1] "Sun Jun 14 19:11:19 2015"

``` r
test_dir("tests/")
Expand Down
Binary file modified README_files/figure-markdown_github/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Rforecastio.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --resave-data
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace
2 changes: 1 addition & 1 deletion man/forecastio_api_key.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{forecastio_api_key}
\title{Get or set FORECASTIO_API_KEY value}
\usage{
forecastio_api_key(force = FALSE, time.formatter = as.POSIXct, ...)
forecastio_api_key(force = FALSE)
}
\arguments{
\item{force}{force setting a new ForecastIO API key for the current environment?}
Expand Down
2 changes: 1 addition & 1 deletion man/get_forecast_for.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ for more information.
You must have \code{FORECASTIO_API_KEY} in you \code{.Renvion} file for this to work
}
\examples{
tmp <- get_current_forecast_for(37.8267,-122.423, "2013-05-06T12:00:00-0400")
tmp <- get_forecast_for(37.8267,-122.423, "2013-05-06T12:00:00-0400")
}

8 changes: 4 additions & 4 deletions man/plot.rforecastio.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
% Please edit documentation in R/plot.R
\name{plot.rforecastio}
\alias{plot.rforecastio}
\title{Plot method for rforecastio objects:}
\title{Plot method for rforecastio xs:}
\usage{
\method{plot}{rforecastio}(object, ..., readings = c("hourly", "minutely",
\method{plot}{rforecastio}(x, ..., readings = c("hourly", "minutely",
"daily"))
}
\arguments{
\item{object}{an rforecastio object}
\item{x}{an rforecastio x}

\item{readings}{specify which readings to plot. will plot all available by default}

Expand All @@ -18,6 +18,6 @@
frame grob
}
\description{
Uses ggplot2 & grid.arrange to produce graphs for rforecastio objects
Uses ggplot2 & grid.arrange to produce graphs for rforecastio xs
}

0 comments on commit 518621c

Please sign in to comment.