-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec2056a
commit d5006fa
Showing
2 changed files
with
25 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters