From 4540ddec829b262d2e558f4e183c4a4f437b3666 Mon Sep 17 00:00:00 2001 From: rafapereirabr Date: Thu, 21 Sep 2023 09:49:37 -0300 Subject: [PATCH] v1.8.1 --- r-package/DESCRIPTION | 2 +- r-package/NEWS.md | 8 +++++- r-package/cran-comments.md | 6 ++--- r-package/tests/tests_rafa/test_rafa.R | 7 +---- r-package/vignettes/intro_to_geobr.Rmd | 36 ++++++++++++++------------ 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/r-package/DESCRIPTION b/r-package/DESCRIPTION index a49e335f..91252666 100644 --- a/r-package/DESCRIPTION +++ b/r-package/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: geobr Title: Download Official Spatial Data Sets of Brazil -Version: 1.8.0 +Version: 1.8.1 Authors@R: c(person(given="Rafael H. M.", family="Pereira", email="rafa.pereira.br@gmail.com", role=c("aut", "cre"), comment = c(ORCID = "0000-0003-2125-7465")), person(given="Caio Nogueira", family="Goncalves", role=c("aut")), person(given="Paulo Henrique Fernandes de", family="Araujo", role=c("ctb")), diff --git a/r-package/NEWS.md b/r-package/NEWS.md index 1510b204..ca9837ea 100644 --- a/r-package/NEWS.md +++ b/r-package/NEWS.md @@ -1,5 +1,11 @@ +# geobr v1.8.1 -# geobr v1.7.0999 (dev version) +**CRAN request** +- geobr now uses suggested packages conditionally + + + +# geobr v1.8.0 **New function** - `read_capitals()` to download either a spatial `sf` object with the location of the municipal seats (sede dos municipios) of state capitals, or a `data.frame` with the names of codes of state capitals. [Closes #243](https://github.com/ipeaGIT/geobr/issues/243) diff --git a/r-package/cran-comments.md b/r-package/cran-comments.md index 0c79fbf0..2028adab 100644 --- a/r-package/cran-comments.md +++ b/r-package/cran-comments.md @@ -1,5 +1,5 @@ -## ── R CMD check results ───────────────────────────────────── geobr 1.8.0 ──── -Duration: 8m 3.8s +── R CMD check results ─────────────────────────────────────────────────────────────────────────────── geobr 1.8.1 ──── +Duration: 7m 49.9s ❯ checking data for non-ASCII characters ... NOTE Note: found 58 marked UTF-8 strings @@ -7,5 +7,5 @@ Duration: 8m 3.8s 0 errors ✔ | 0 warnings ✔ | 1 note ✖ -* Update to version v.1.8.0 with one new function and a few bug fixes. +* geobr now uses suggested packages conditionally diff --git a/r-package/tests/tests_rafa/test_rafa.R b/r-package/tests/tests_rafa/test_rafa.R index add9aca9..b5d29c93 100644 --- a/r-package/tests/tests_rafa/test_rafa.R +++ b/r-package/tests/tests_rafa/test_rafa.R @@ -554,12 +554,7 @@ rhub::check_for_cran(show_status = FALSE) # submit to CRAN ----------------- usethis::use_cran_comments('teste 2222, , asdadsad') - -Sys.setenv(NOT_CRAN = "true") -devtools::submit_cran() - - - +1 # build binary -------------------------------- diff --git a/r-package/vignettes/intro_to_geobr.Rmd b/r-package/vignettes/intro_to_geobr.Rmd index e36ea9a5..b5267a0e 100644 --- a/r-package/vignettes/intro_to_geobr.Rmd +++ b/r-package/vignettes/intro_to_geobr.Rmd @@ -14,6 +14,14 @@ knitr::opts_chunk$set( eval = identical(tolower(Sys.getenv("NOT_CRAN")), "true"), out.width = "100%" ) + + +use_suggested_pkgs <- c((requireNamespace("dplyr")), + (requireNamespace("scales")), + (requireNamespace("ggplot2")), + (requireNamespace("censobr"))) + +use_suggested_pkgs <- all(use_suggested_pkgs) ``` @@ -36,7 +44,7 @@ devtools::install_github("ipeaGIT/geobr", subdir = "r-package") Now let's load the libraries we'll use in this vignette. -```{r eval=TRUE, message=FALSE, warning=FALSE, results='hide'} +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'} library(geobr) library(ggplot2) library(sf) @@ -51,7 +59,7 @@ library(dplyr) The geobr package covers 27 spatial data sets, including a variety of political-administrative and statistical areas used in Brazil. You can view what data sets are available using the `list_geobr()` function. -```{r eval=TRUE, message=FALSE, warning=FALSE} +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE} # Available data sets datasets <- list_geobr() @@ -65,7 +73,7 @@ head(datasets) The syntax of all *geobr* functions operate one the same logic, so the code to download the data becomes intuitive for the user. Here are a few examples. Download an specific geographic area at a given year -```{r eval=TRUE, message=FALSE, warning=FALSE} +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE} # State of Sergige state <- read_state( code_state="SE", @@ -133,7 +141,7 @@ All functions to download polygon data such as states, municipalities etc. have Once you've downloaded the data, it is really simple to plot maps using `ggplot2`. -```{r eval=TRUE, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"} +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"} # Remove plot axis no_axis <- theme(axis.title=element_blank(), axis.text=element_blank(), @@ -149,13 +157,10 @@ ggplot() + ``` -```{r states br, eval=FALSE, echo=FALSE, message=FALSE, out.width='100%'} -knitr::include_graphics("https://github.com/ipeaGIT/geobr/blob/master/r-package/inst/img/states_br.png?raw=true") -``` Plot all the municipalities of a particular state, such as Rio de Janeiro: -```{r eval=TRUE, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"} +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"} # Download all municipalities of Rio all_muni <- read_municipality( @@ -173,9 +178,6 @@ ggplot() + ``` -```{r munis rio, eval=FALSE, echo=FALSE, message=FALSE, out.width='100%'} -knitr::include_graphics("https://github.com/ipeaGIT/geobr/blob/master/r-package/inst/img/munis_rj.png?raw=true") -``` ## Thematic maps @@ -185,7 +187,7 @@ The next step is to combine data from ***geobr*** package with other data sets First, we need a `data.frame` with estimates of Life Expectancy and merge it to our spatial database. The two-digit abbreviation of state name is our key column to join these two databases. -```{r eval=TRUE, message=FALSE, warning=FALSE, results='hide'} +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'} # Read data.frame with life expectancy data df <- utils::read.csv(system.file("extdata/br_states_lifexpect2017.csv", package = "geobr"), encoding = "UTF-8") @@ -200,7 +202,7 @@ states <- dplyr::left_join(states, df, by = c("name_state" = "uf")) #### Plot thematic map -```{r eval=TRUE, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center" } +```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center" } ggplot() + geom_sf(data=states, aes(fill=ESPVIDA2017), color= NA, size=.15) + labs(subtitle="Life Expectancy at birth, Brazilian States, 2014", size=8) + @@ -216,7 +218,9 @@ Following the same steps as above, we can use together **geobr** with our sister First, we need to download households data from the Brazilian census using the `read_households()` function. -```{r, eval = TRUE} + + +```{r, eval = use_suggested_pkgs } library(censobr) hs <- read_households(year = 2010, @@ -226,7 +230,7 @@ hs <- read_households(year = 2010, Now we're going to (a) group observations by municipality, (b) get the number of households connected to a sewage network, (c) calculate the proportion of households connected, and (d) collect the results. -```{r, eval = TRUE, warning = FALSE} +```{r, eval = use_suggested_pkgs, warning = FALSE} esg <- hs |> collect() |> group_by(code_muni) |> # (a) @@ -239,7 +243,7 @@ head(esg) ``` Now we only need to download the geometries of Brazilian municipalities from **geobr**, merge the spatial data with our estimates and map the results. -```{r, eval = TRUE, warning = FALSE} +```{r, eval = use_suggested_pkgs, warning = FALSE} # download municipality geometries muni_sf <- geobr::read_municipality(year = 2010, showProgress = FALSE)