Skip to content

Commit

Permalink
v1.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rafapereirabr committed Jan 9, 2024
1 parent e375fdc commit 7fa67a3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion r-package/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: geobr
Title: Download Official Spatial Data Sets of Brazil
Version: 1.8.999
Version: 1.8.2
Authors@R: c(person(given="Rafael H. M.", family="Pereira", email="[email protected]", 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")),
Expand Down
4 changes: 2 additions & 2 deletions r-package/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# geobr v1.8.999 dev
# geobr v1.8.2

**CRAN request**
- Fixed issue to nake sure geobr uses suggested packages conditionally
- Fixed issue to make sure geobr uses suggested packages conditionally

**Minor changes**
- Fixed non-ASCII characters in data `geobr::grid_state_correspondence_table()`
Expand Down
14 changes: 8 additions & 6 deletions r-package/cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
── R CMD check results ─────────────────────────────────────────────────────────────────────────────── geobr 1.8.1 ────
Duration: 7m 49.9s
── R CMD check results ────────────────────────────────────────────────── geobr 1.8.2 ────
Duration: 6m 47.4s

❯ checking data for non-ASCII characters ... NOTE
Note: found 58 marked UTF-8 strings
0 errors ✔ | 0 warnings ✔ | 0 notes ✔

0 errors ✔ | 0 warnings ✔ | 1 note ✖


* geobr now uses suggested packages conditionally
**CRAN request**
- Fixed issue to make sure geobr uses suggested packages conditionally on CRAN

**Minor changes**
- Fixed non-ASCII characters in data `geobr::grid_state_correspondence_table()`

1 change: 1 addition & 0 deletions r-package/man/geobr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion r-package/tests/tests_rafa/test_rafa.R
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@ rhub::check_for_cran(show_status = FALSE)
# submit to CRAN -----------------
usethis::use_cran_comments('teste 2222, , asdadsad')

1
devtools::submit_cran()




# build binary --------------------------------
Expand Down
30 changes: 12 additions & 18 deletions r-package/vignettes/intro_to_geobr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ knitr::opts_chunk$set(
)
use_suggested_pkgs <- c((requireNamespace("dplyr")),
(requireNamespace("scales")),
(requireNamespace("ggplot2")),
(requireNamespace("censobr")))
use_suggested_pkgs <- all(use_suggested_pkgs)
```


Expand All @@ -44,7 +38,7 @@ devtools::install_github("ipeaGIT/geobr", subdir = "r-package")

Now let's load the libraries we'll use in this vignette.

```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'}
```{r message=FALSE, warning=FALSE, results='hide'}
library(geobr)
library(ggplot2)
library(sf)
Expand All @@ -59,7 +53,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=use_suggested_pkgs, message=FALSE, warning=FALSE}
```{r message=FALSE, warning=FALSE}
# Available data sets
datasets <- list_geobr()
Expand All @@ -73,7 +67,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=use_suggested_pkgs, message=FALSE, warning=FALSE}
```{r message=FALSE, warning=FALSE}
# State of Sergige
state <- read_state(
code_state="SE",
Expand All @@ -95,7 +89,7 @@ ggplot() +


Download all geographic areas within a state at a given year
```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'}
```{r message=FALSE, warning=FALSE, results='hide'}
# All municipalities in the state of Minas Gerais
muni <- read_municipality(code_muni = "MG",
year = 2007,
Expand All @@ -113,7 +107,7 @@ head(muni)

If the parameter `code_` is not passed to the function, geobr returns the data for the whole country by default.

```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE}
```{r message=FALSE, warning=FALSE}
# read all intermediate regions
inter <- read_intermediate_region(
year = 2017,
Expand Down Expand Up @@ -141,7 +135,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=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
```{r 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(),
Expand All @@ -160,7 +154,7 @@ ggplot() +

Plot all the municipalities of a particular state, such as Rio de Janeiro:

```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
```{r message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center"}
# Download all municipalities of Rio
all_muni <- read_municipality(
Expand All @@ -187,7 +181,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=use_suggested_pkgs, message=FALSE, warning=FALSE, results='hide'}
```{r 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")
Expand All @@ -202,7 +196,7 @@ states <- dplyr::left_join(states, df, by = c("name_state" = "uf"))

#### Plot thematic map

```{r eval=use_suggested_pkgs, message=FALSE, warning=FALSE, fig.height = 8, fig.width = 8, fig.align = "center" }
```{r 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) +
Expand All @@ -220,7 +214,7 @@ First, we need to download households data from the Brazilian census using the `



```{r, eval = use_suggested_pkgs }
```{r}
library(censobr)
hs <- read_households(year = 2010,
Expand All @@ -230,7 +224,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 = use_suggested_pkgs, warning = FALSE}
```{r, warning = FALSE}
esg <- hs |>
collect() |>
group_by(code_muni) |> # (a)
Expand All @@ -243,7 +237,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 = use_suggested_pkgs, warning = FALSE}
```{r, warning = FALSE}
# download municipality geometries
muni_sf <- geobr::read_municipality(year = 2010,
showProgress = FALSE)
Expand Down

0 comments on commit 7fa67a3

Please sign in to comment.