From 8a021c936afb594f59199619462ce205c43507ed Mon Sep 17 00:00:00 2001 From: rafapereirabr Date: Mon, 23 Dec 2024 09:33:46 -0300 Subject: [PATCH] reprex in readme and vignette --- README.Rmd | 32 +++++++++++++++++++++++++++++++- vignettes/geocodebr.Rmd | 26 +++++++++++++++----------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/README.Rmd b/README.Rmd index 87c708b..b1a7306 100644 --- a/README.Rmd +++ b/README.Rmd @@ -40,7 +40,37 @@ pak::pak("ipeaGIT/geocodebr") ## Usage -Soon. + +## Usage + +```{r, eval=FALSE} +library(geocodebr) + +# input data +data_path <- system.file("extdata/small_sample.csv", package = "geocodebr") +input_df <- read.csv(data_path) + +# indicate the columns describing the address fields +fields <- setup_address_fields( + logradouro = "nm_logradouro", + numero = "Numero", + cep = "Cep", + bairro = "Bairro", + municipio = "nm_municipio", + estado = "nm_uf" + ) + +# geocode +df <- geocode( + addresses_table = input_df, + address_fields = fields, + n_cores = 1, + progress = TRUE + ) + +``` + + ## Acknowledgement IPEA diff --git a/vignettes/geocodebr.Rmd b/vignettes/geocodebr.Rmd index 0bc5c6f..88fd079 100644 --- a/vignettes/geocodebr.Rmd +++ b/vignettes/geocodebr.Rmd @@ -23,27 +23,31 @@ knitr::opts_chunk$set( Reprex ```{r, eval = FALSE} - library(geocodebr) # open input data -data_path <- system.file("extdata/sample_1.csv", package = "geocodebr") +data_path <- system.file("extdata/small_sample.csv", package = "geocodebr") input_df <- read.csv(data_path) -geo_duck <- geocode_duck2( - input_table = input_df, +# indicate the columns describing the address fields +fields <- setup_address_fields( logradouro = "nm_logradouro", numero = "Numero", - complemento = "Complemento", cep = "Cep", bairro = "Bairro", municipio = "nm_municipio", - estado = "nm_uf", - output_simple = TRUE, - ncores = NULL, - showProgress = TRUE -) - + estado = "nm_uf" + ) + +# geocode +df <- geocode( + addresses_table = input_df, + address_fields = fields, + n_cores = 1, + progress = TRUE + ) + +head(df) ```