Browse Source

CRAN checks

master
boB Rudis 4 years ago
parent
commit
a4c2ad05e0
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 3
      DESCRIPTION
  2. 1
      NAMESPACE
  3. 1
      R/f5wx-package.R
  4. 57
      R/main.R
  5. 8
      README.Rmd
  6. 29
      README.md
  7. 4
      man/f5wx_forecast.Rd

3
DESCRIPTION

@ -17,7 +17,7 @@ License: AGPL
Suggests:
covr, tinytest
Depends:
R (>= 3.5.0)
R (>= 3.6.0)
Imports:
dplyr,
forcats,
@ -30,6 +30,7 @@ Imports:
stringi,
tibble,
tidyr,
utils,
xml2
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1

1
NAMESPACE

@ -22,3 +22,4 @@ importFrom(forcats,fct_rev)
importFrom(magrittr,"%>%")
importFrom(tibble,as_tibble)
importFrom(tidyr,replace_na)
importFrom(utils,globalVariables)

1
R/f5wx-package.R

@ -12,4 +12,5 @@
#' @importFrom dplyr bind_rows mutate filter count rename left_join
#' @importFrom forcats fct_rev fct_inorder
#' @importFrom tidyr replace_na
#' @importFrom utils globalVariables
"_PACKAGE"

57
R/main.R

@ -1,3 +1,7 @@
utils::globalVariables(
c("V1", "V2", "V3", "c_alpha", "conditions")
)
#' Start a session to F5 Weather
#'
#' @param user,pass F5 Weather creds; use `F5WX_USER` & `F5WX_PASS` environment
@ -59,7 +63,9 @@ f5wx_login <- function(user = Sys.getenv("F5WX_USER"),
#' Retrieve a forecast table from F5 Weather
#'
#' @param search for this location
#' @return httr `response` object
#' @return `f5wx_cast` object which is a `list` that contains a data frame of
#' forecast information and an httr `response` object in the event
#' you want to do more processing of the HTML table
#' @export
#' @examples \dontrun{
#' library(ggplot2)
@ -101,23 +107,6 @@ f5wx_forecast <- function(search = "Dover, NH") {
httr::stop_for_status(res)
invisible(res)
}
#' Make a temperature & precipitation chart from the object returned by [f5wx_forecast()]
#'
#' @param res object returned by [f5wx_forecast()]
#' @return ggplot2 object
#' @export
#' @examples \dontrun{
#' library(ggplot2)
#' f5wx_login()
#' res <- f5wx_forecast()
#' f5wx_chart(res) + labs(title = "ECMWF Forecast for Berwick, Maine")
#' }
f5wx_chart <- function(res) {
pg <- httr::content(res, as = "parsed")
# model date location elevation in the <td>
@ -179,6 +168,34 @@ f5wx_chart <- function(res) {
c_alpha = replace_na(c_alpha, 1)
) -> f_cast
list(
f_cast = f_cast,
response = res
) -> out
class(out) <- c("f5wx_cast", "list")
invisible(out)
}
#' Make a temperature & precipitation chart from the object returned by [f5wx_forecast()]
#'
#' @param res object returned by [f5wx_forecast()]
#' @return ggplot2 object
#' @export
#' @examples \dontrun{
#' library(ggplot2)
#' f5wx_login()
#' res <- f5wx_forecast()
#' f5wx_chart(res) + labs(title = "ECMWF Forecast for Berwick, Maine")
#' }
f5wx_chart <- function(res) {
stopifnot(inherits(res, "f5wx_cast"))
f_cast <- res$f_cast
ggplot() +
geom_segment(
data = f_cast,
@ -186,11 +203,11 @@ f5wx_chart <- function(res) {
size = 5, lineend = "round"
) +
geom_text(
data = f_cast, aes(V2, V1, label = sprintf("%s°", V2)),
data = f_cast, aes(V2, V1, label = sprintf("%s\u00B0", V2)),
hjust = 1, nudge_x = -0.75, size = 4, family = font_gs
) +
geom_text(
data = f_cast, aes(V3, V1, label = sprintf("%s°", V3)),
data = f_cast, aes(V3, V1, label = sprintf("%s\u00B0", V3)),
hjust = 0, nudge_x = 0.75, size = 4, family = font_gs
) +
scale_x_continuous(

8
README.Rmd

@ -41,11 +41,15 @@ packageVersion("f5wx")
```{r ex01, fig.width=750/96, fig.height=450/96}
library(ggplot2)
library(tibble)
f5wx_login()
f5wx_forecast() %>%
f5wx_chart() +
res <- f5wx_forecast()
res$f_cast
f5wx_chart(res) +
labs(title = "ECMWF Forecast for Berwick, Maine")
```

29
README.md

@ -9,7 +9,7 @@ by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keyb
[![Linux build
Status](https://travis-ci.org/hrbrmstr/f5wx.svg?branch=master)](https://travis-ci.org/hrbrmstr/f5wx)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.5.0-blue.svg)
Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg)
![License](https://img.shields.io/badge/License-AGPL-blue.svg)
# f5wx
@ -55,11 +55,28 @@ packageVersion("f5wx")
``` r
library(ggplot2)
library(tibble)
f5wx_login()
f5wx_forecast() %>%
f5wx_chart() +
res <- f5wx_forecast()
res$f_cast
## # A tibble: 10 x 5
## V1 V2 V3 conditions c_alpha
## <fct> <int> <int> <chr> <dbl>
## 1 Sat 10/3 46 67 Clear 1
## 2 Sun 10/4 45 68 Clear 1
## 3 Mon 10/5 52 63 Rain 1
## 4 Tue 10/6 48 68 Clear 1
## 5 Wed 10/7 53 61 Rain 0.25
## 6 Thu 10/8 50 56 Clear 1
## 7 Fri 10/9 41 46 Clear 1
## 8 Sat 10/10 38 51 Clear 1
## 9 Sun 10/11 46 60 Clear 1
## 10 Mon 10/12 50 61 Clear 1
f5wx_chart(res) +
labs(title = "ECMWF Forecast for Berwick, Maine")
```
@ -69,9 +86,9 @@ f5wx_forecast() %>%
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | --: | --: | ---: | ----------: | --: | -------: | ---: |
| R | 4 | 0.4 | 161 | 0.46 | 26 | 0.3 | 59 | 0.33 |
| Rmd | 1 | 0.1 | 13 | 0.04 | 18 | 0.2 | 30 | 0.17 |
| SUM | 5 | 0.5 | 174 | 0.50 | 44 | 0.5 | 89 | 0.50 |
| R | 4 | 0.4 | 171 | 0.46 | 31 | 0.3 | 62 | 0.34 |
| Rmd | 1 | 0.1 | 15 | 0.04 | 20 | 0.2 | 30 | 0.16 |
| SUM | 5 | 0.5 | 186 | 0.50 | 51 | 0.5 | 92 | 0.50 |
clock Package Metrics for f5wx

4
man/f5wx_forecast.Rd

@ -10,7 +10,9 @@ f5wx_forecast(search = "Dover, NH")
\item{search}{for this location}
}
\value{
httr \code{response} object
\code{f5wx_cast} object which is a \code{list} that contains a data frame of
forecast information and an httr \code{response} object in the event
you want to do more processing of the HTML table
}
\description{
Retrieve a forecast table from F5 Weather

Loading…
Cancel
Save