Skip to content

Commit 0054e79

Browse files
committed
closes #31
1 parent 2fbeca6 commit 0054e79

15 files changed

+11
-99
lines changed

r-package/DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: aopdata
22
Title: Data from the 'Access to Opportunities Project (AOP)'
3-
Version: 0.2.0
4-
Date: 2021-03-30
3+
Version: 0.2.1
4+
Date: 2021-04-07
55
Authors@R: c(
66
person(given="Rafael H. M.", family="Pereira", email="[email protected]", role=c("aut", "cre"), comment = c(ORCID = "0000-0003-2125-7465")),
77
person(given="Daniel", family="Herszenhut", email="[email protected]", role="aut", comment = c(ORCID = "0000-0001-8066-1105")),

r-package/NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export(read_access)
1010
export(read_grid)
1111
export(read_landuse)
1212
export(read_population)
13-
export(rm_accent)
1413
export(select_city_input)
1514
export(select_metadata)
1615
export(select_mode_input)

r-package/NEWS.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
-------------------------------------------------------
44

55

6-
# aopdata v0.3.0 (dev)
7-
8-
**Major changes**
9-
* Allow for user to download data few selected cities. Closes #29
10-
6+
# aopdata v0.2.1 (dev)
117

128
**Minor changes**
9+
* Allow for user to download data few selected cities. Closes #29
1310
* Fix progress bar even when showProgress = F. Closes #30
11+
* Fix encoding issues using `base::iconv(city, to="ASCII//TRANSLIT")`. Closes #31
1412

1513

1614
-------------------------------------------------------

r-package/R/read_access.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ read_access <- function(city, mode = 'walk', peak = TRUE, year = 2019, geometry
9393
aop_access <- download_data(file_url, progress_bar = showProgress)
9494

9595
# peak Vs off-peak
96-
city <- tolower(city)
97-
city <- rm_accent(city)
96+
city <- tolower(city)
97+
# remove accents
98+
city <- base::iconv(city, to="ASCII//TRANSLIT")
9899

99100
cities_with_pt <- ( all(city %in% c('for', 'rec', 'bho', 'rio', 'spo', 'cur', 'poa')) |
100101
all(city %in% c('fortaleza', 'recife', 'belo horizonte',
101-
'rio de janeiro', 's\u00e3o paulo', 'sao paulo', 'curitiba', 'porto alegre')) )
102+
'rio de janeiro', 'sao paulo', 'curitiba', 'porto alegre')) )
102103

103104
if (isFALSE(cities_with_pt) & mode == 'public_transport') {stop("One of the selected cities does not have public transport data for that year.")}
104105

r-package/R/utils.R

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ select_city_input <- function(temp_meta=temp_meta, city=NULL){
4040
if (all(nchar(city)>3)) {
4141

4242
city <- tolower(city)
43-
city <- rm_accent(city)
43+
# remove accents
44+
city <- base::iconv(city, to="ASCII//TRANSLIT")
4445

4546
# valid input
4647
if (all(city %in% temp_meta$name_muni)) { temp_meta <- temp_meta[ temp_meta$name_muni %in% city, ]
@@ -344,52 +345,6 @@ load_data <- function(file_url, temps=NULL){
344345

345346

346347

347-
348-
#' Remove accents from string
349-
#'
350-
#' @description Removes non-ASCII characters from a string.
351-
#'
352-
#' @param str A string
353-
#' @param pattern A pattern
354-
#'
355-
#' @return Returns a string with non-ASCII characters replaced with "\'uxxxx" escapes
356-
#'
357-
#' @export
358-
#' @family support functions
359-
#'
360-
rm_accent <- function(str, pattern="all") {
361-
if(!is.character(str))
362-
str <- as.character(str)
363-
pattern <- unique(pattern)
364-
if(any(pattern=="\u00c7"))
365-
pattern[pattern=="\u00c7"] <- "\u00e7"
366-
symbols <- c(
367-
acute = "\u00e1\u00e9\u00ed\u00f3\u00fa\u00c1\u00c9\u00cd\u00d3\u00da\u00fd\u00dd",
368-
grave = "\u00e0\u00e8\u00ec\u00f2\u00f9\u00c0\u00c8\u00cc\u00d2\u00d9",
369-
circunflex = "\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db",
370-
tilde = "\u00e3\u00f5\u00c3\u00d5\u00f1\u00d1",
371-
umlaut = "\u00e4\u00eb\u00ef\u00f6\u00fc\u00c4\u00cb\u00cf\u00d6\u00dc\u00ff",
372-
cedil = "\u00e7\u00c7"
373-
)
374-
nudeSymbols <- c(
375-
acute = "aeiouAEIOUyY",
376-
grave = "aeiouAEIOU",
377-
circunflex = "aeiouAEIOU",
378-
tilde = "aoAOnN",
379-
umlaut = "aeiouAEIOUy",
380-
cedil = "cC"
381-
)
382-
accentTypes <- c("\u00b4", "`", "^", "~", "\u00a8", "\u00e7") # c("´","`","^","~","¨","ç")
383-
if(any(c("all","al","a","todos","t","to","tod","todo")%in%pattern))
384-
return(chartr(paste(symbols, collapse=""), paste(nudeSymbols, collapse=""), str))
385-
for(i in which(accentTypes%in%pattern))
386-
str <- chartr(symbols[i],nudeSymbols[i], str)
387-
return(str)
388-
}
389-
390-
391-
392-
393348
#' Spatial join of AOP data
394349
#'
395350
#' @description Merges landuse or access data with H3 grid geometries

r-package/man/aop_merge.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r-package/man/aop_spatial_join.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r-package/man/check_connection.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r-package/man/download_data.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

r-package/man/load_data.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)