Skip to content

Commit

Permalink
Write to feather
Browse files Browse the repository at this point in the history
  • Loading branch information
j-hagedorn committed Sep 5, 2017
1 parent ec2056a commit d5006fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
46 changes: 21 additions & 25 deletions prep/scrub.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
# scrub.R #

#### Aggregate data to allow presentation in open app
# Script to scrub PHI from SIS data to use with Shiny Apps

library(dplyr)
library(tidyr)
library(car)
# Make an ID key
mcaid_id <- unique(locus$consumer_id)
sis_key <- data.frame(mcaid_id)
sis_key$fake_id <- sample(x = 100000001:999999999,
size = length(sis_key$mcaid_id),
replace = FALSE)
sis_key$mcaid_id <- as.character(sis_key$mcaid_id)
sis_key$fake_id <- as.character(sis_key$fake_id)
rm(mcaid_id)

# Define dataset without PHI to use with Shiny Apps
# Make PHI-free dataset
scrub_sis <-
sub_sis %>%
mutate(mcaid_id = as.character(mcaid_id)) %>%
left_join(sis_key, by = "mcaid_id") %>%
select(-sis_id, -mcaid_id, -age, -gender, -address)

# Make an ID key
mcaid_id <- unique(sub_sis$mcaid_id)
sis_key <- data.frame(mcaid_id)
sis_key$fake_id <- sample(x = 100000001:999999999,
size = length(sis_key$mcaid_id),
replace = FALSE)
sis_key$mcaid_id <- as.character(sis_key$mcaid_id)
sis_key$fake_id <- as.character(sis_key$fake_id)
rm(mcaid_id)

# Make PHI-free dataset
scrub_sis <-
sub_sis %>%
mutate(mcaid_id = as.character(mcaid_id)) %>%
left_join(sis_key, by = "mcaid_id") %>%
select(-sis_id, -mcaid_id, -age, -gender, -address)

# Write SIS Key and Scrubbed data to local workspace
write.csv(sis_key,"data/sis_key.csv", row.names = F)
write.csv(scrub_sis,"data/scrub_sis.csv", row.names = F)
# Write SIS Key and Scrubbed data to local workspace
write.csv(sis_key,"data/sis_key.csv", row.names = F)
library(feather)
write_feather(scrub_sis,"data/scrub_sis.feather")
6 changes: 4 additions & 2 deletions prep/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,7 @@ q3 <-
"Not endorsed")))) %>%
select(-import_to_n, -import_for_n, -n)

saveRDS(q2,"data/q2.rds")
saveRDS(q3,"data/q3.rds")
library(feather)
write_feather(q2,"data/q2.feather")
write_feather(q3,"data/q3.feather")

0 comments on commit d5006fa

Please sign in to comment.