## Warning: package 'tibble' was built under R version 3.5.2
## Warning: package 'purrr' was built under R version 3.5.2
## Warning: package 'rlang' was built under R version 3.5.2

Introduction

A primary purpose of this package is to check raw MDS data, format and prepare it for a ‘tidy’ analytical dataset.

The following sections demonstrate examples:

Test that mds data.frame is canonical

For the package to work it must:

  1. Be a ‘data.frame’, ‘tbl’ class object.

  2. Have named variables consistent with mdsR internal data dictionary

Calling mdsR internal data

Most functions will call an internal dictionary, when checking whether variables are properly formatted etc. The guides mdsR to what kind of a variable a column is, what to label it, whether it is a common mds ResDAC item or something Brown generates for its own server purposes etc. It only works if the data frame is set-up properly.

Test non-canon file

not_mds_dta <- cars
mds_as_canon(not_mds_dta)
#> mds_obj  is data.frame.... TRUE 
#> mds_obj  is tibble.... FALSE 
#> mds_obj  has core variables.... FALSE 
#> mds_obj  all variables "std".... FALSE 
#> mds_obj  has "non-std" variables.... FALSE 
#> non-canon variables... speed, dist, 
#> mds_obj  is mds canon.... FALSE

Test canon file

mds_dta <- mdsR::mds_dta  
mds_dta <- mds_as_canon(mds_dta)
#> mds_obj  is data.frame.... TRUE 
#> mds_obj  is tibble.... TRUE 
#> mds_obj  has core variables.... TRUE 
#> mds_obj  all variables "std".... FALSE 
#> mds_obj  has "non-std" variables.... TRUE 
#> non-canon variables... DMREPPROV, M3A0100A, M3A0100B, M3A0100C, mmxxid, mmxxidp, PROV1680_0, PROV1680_1, M3A1600, DMASMDT, 
#> mds_obj  is mds canon.... TRUE

quick check

mds_is_canon(mds_dta)
#> [1] TRUE

Check missingness

mds_flagmiss(mds_dta, .table=F)
#> MDS variables with >10% missingness... 
#> ...none

Report table of missingness

mds_flagmiss(mds_dta, .cutoff=0, .table=T)
#> MDS variables with >10% missingness...
#>          varlist count_na
#> 1        DMREPID        0
#> 2  bene_id_18900        0
#> 3       accpt_id        0
#> 4      DMREPPROV        0
#> 5       M3A0100A        0
#> 6       M3A0100B        0
#> 7       M3A0100C        0
#> 8         mmxxid        0
#> 9        mmxxidp        0
#> 10    PROV1680_0        0
#> 11    PROV1680_1        0
#> 12       DMRECID        0
#> 13       M3A0900        0
#> 14       M3A1600        0
#> 15       M3A2000        0
#> 16       DMASMDT        0
#> 17        dmdate        0
#> 18       M3A0800        0

Check variables for formatting

Brown specialty variables