Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes subsetting in extract_related_topics and data processing for Namibia #353

Merged
merged 4 commits into from
Jun 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/related_topics.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ create_related_topics_payload <- function(i, widget, hl, tz) {
extract_related_topics <- function(i, raw_data) {

n <- length(raw_data)
end <- min(which(raw_data[i:n] == ""))
end <- i + min(which(raw_data[i:n] == "")) - 1

df <- read.csv(textConnection(raw_data[i:end]), row.names = NULL)
df$subject <- rownames(df)
Expand Down
Binary file modified R/sysdata.rda
100755 → 100644
Binary file not shown.
15 changes: 14 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,20 @@ get_widget <- function(comparison_item, category, gprop, hl, cookie_url, tz) {
Encoding(temp) <- "UTF-8"

myjs <- jsonlite::fromJSON(substring(temp, first = 6))


# The above will silently convert strings containing "NA" to
# a logical NA (see: https://github.com/jeroen/jsonlite/issues/314)
# There currently is no way to fix this other than setting simplifyVector = F
# which likely breaks other things. Thus what follows is a hacky fix to
# catch the likely case that somebody is looking for searches with
# geo="NA"
if (is.logical(myjs$widgets$request$comparisonItem[[1]]$geo$country)) {
myjs$widgets$request$comparisonItem[[1]]$geo$country <- comparison_item$geo
myjs$widgets$request$geo$country <- comparison_item$geo
myjs$widgets$request$restriction$geo$country <- comparison_item$geo
myjs$widgets$geo <- comparison_item$geo
}

widget <- myjs$widgets
}

Expand Down
2 changes: 1 addition & 1 deletion data-raw/process_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ get_countries <- function() {
stopifnot(ret == 0)

# , col.names = c("country_code", "sub_code", "country")
countries <- read.csv(destfile)
countries <- read.csv(destfile, na.strings = "")

# Fix the encoding
countries <- data.frame(sapply(countries, iconv, to = "ASCII//TRANSLIT"))
Expand Down
Binary file modified data/categories.rda
100755 → 100644
Binary file not shown.
Binary file modified data/countries.rda
100755 → 100644
Binary file not shown.