Skip to content

Commit

Permalink
Regex to pull out checkbox values.
Browse files Browse the repository at this point in the history
Proof-of-concept  -not generalized.  See #138
  • Loading branch information
wibeasley committed Feb 26, 2017
1 parent 5e8e1f9 commit a5ec52b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions playgrounds/eav-playground.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ ds_eav <- readr::read_csv(raw_text)

# ---- tweak-data --------------------------------------------------------------

# ds_checkbox <- ds_metadata %>%
# dplyr::filter(field_type=="checkbox")
ds_checkbox <- ds_metadata %>%
dplyr::filter(field_type=="checkbox")

ds_eav_2 <- ds_eav %>%
dplyr::left_join(
Expand Down Expand Up @@ -75,6 +75,16 @@ ds_2 <- ds %>%
.funs = function(x) !is.na(x) # If there's any value, then it's TRUE. Missingness is converted to FALSE.
)

strsplit(ds_checkbox$select_choices_or_calculations[[1]], split="\\s*\\|\\s*", perl=F)[[1]]

checkbox_ids <-
ds_checkbox$select_choices_or_calculations[1] %>%
strsplit( split="\\s*\\|\\s*", perl=F) %>%
.[[1]] %>%
gsub("(\\d{1,}),\\s*.+", "\\1", ., perl=T) %>%
as.integer()


# ---- verify-values -----------------------------------------------------------
setdiff(colnames(ds_expected), colnames(ds_2))
setdiff(colnames(ds_2), colnames(ds_expected))
Expand Down

0 comments on commit a5ec52b

Please sign in to comment.