Once the DUA crosswalk and level have been set, a working data frame can be checked against active data element restrictions. The data frame must pass before it can be writen using write_dua_df().

check_dua_restrictions(df)

Arguments

df

Data frame to check against set DUA restriction level.

Examples

## -------------- ## Setup ## -------------- ## set DUA crosswalk dua_cw <- system.file('extdata', 'dua_cw.csv', package = 'duawranglr') set_dua_cw(dua_cw)
#> -- duawranglr note ------------------------------------------------------------- #> DUA crosswalk has been set!
## read in data admin <- system.file('extdata', 'admin_data.csv', package = 'duawranglr') df <- read_dua_file(admin) ## -------------- ## set restriction level set_dua_level('level_iii') ## show restrictions see_dua_level(show_restrictions = TRUE)
#> --------------------------------------------------------------------------------
#> You have set restrictions at [ level_iii ]
#> --------------------------------------------------------------------------------
#> #> RESTRICTED VARIABLE NAMES:
#> - sid
#> - sname
#> - tname
#>
#> --------------------------------------------------------------------------------
## see variables in administrative data file names(df)
#> [1] "sid" "sname" "dob" "gender" "raceeth" "tid" "tname" #> [8] "zip" "mathscr" "readscr"
## remove restrictive variables df <- dplyr::select(df, -c(sid,sname,tname)) ## confirm check_dua_restrictions(df)
#> -- duawranglr note ------------------------------------------------------------- #> Data set has passed check and may be saved.