This function is a wrapper for that will read a variety of file types. The primary reason to use it rather than base R or tidyverse functions is that every new file read will reset the check_pass environment variable to FALSE. This is a security feature in that it requires a new data check each time a new file is read into memory.

read_dua_file(file, ...)

Arguments

file

File name to be read into memory

...

Arguments to pass to read function based on the input type; see details for more information.

Details

The following input types are supported (with the underlying read function and default arguments accompanying):

All arguments for these internal write functions, including those with default values, can be modified by adding them to the top-level read_dua_file() function.

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 file <- system.file('extdata', 'admin_data.csv', package = 'duawranglr') df <- read_dua_file(file) ## show df
#> # A tibble: 9 x 10 #> sid sname dob gender raceeth tid tname zip mathscr readscr #> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 000-00-0001 Schaefer 19900114 0 2 1 Smith 22906 515 496 #> 2 000-00-0002 Hodges 19900225 0 1 1 Smith 22906 488 489 #> 3 000-00-0003 Kirby 19900305 0 4 1 Smith 22906 522 498 #> 4 000-00-0004 Estrada 19900419 0 3 1 Smith 22906 516 524 #> 5 000-00-0005 Nielsen 19900530 1 2 1 Smith 22906 483 509 #> 6 000-00-0006 Dean 19900621 1 1 2 Brown 22906 503 523 #> 7 000-00-0007 Hickman 19900712 1 1 2 Brown 22906 539 509 #> 8 000-00-0008 Bryant 19900826 0 2 2 Brown 22906 499 490 #> 9 000-00-0009 Lynch 19900902 1 3 2 Brown 22906 499 493
if (FALSE) { ## read in other file types read_dua_file('admin_data.rds') read_dua_file('admin_data.txt', sep = '|') read_dua_file('admin_data.dta') read_dua_file('admin_data.xlsx', sheet = 2) }