validate_limits: Use codebook to check continuous variables for validity

Description Usage Arguments Details Value Author(s) Examples

Description

Uses a codebook which is an S3 class codebook, possibly read in by read_codebook, to check for data within valid ranges.

Usage

1
validate_limits(x, code_book, column_names = NULL)

Arguments

x

tibble to which codebook is applied

code_book

codebook containing names of continuous variables and limits for checking data are within range

column_names

character vector of column names for checking data in range. Default: All continuous variables defined in codebook.

Details

REPEAT: Often, when analysing data, data dictionaries or code books are provided with data files. Rather than a word doc or pdf files, the format required here is in a very specific format stored as a csv file. Once read in, attributes such as factor labels/levels and variable labels can be added to the data.frame and/or also used to check factor labels and variable names are consistent with the code book. Note that while various methods may be available which attempt to convert word docs or pdf's to a spreadsheet and/or csv file, extreme care should be taken as these are far from perfect.

Value

object of type class tibble containing data out of limits

Author(s)

Peter Baker pete@petebaker.id.au

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
file.copy(system.file('demoFiles', 'data1_codebook.csv',
                      package='codebookr'), 'data1_codebook.csv')
file.copy(system.file('demoFiles', 'data1-yr21.csv',
                      package='codebookr'), 'data1-yr21.csv')
data1_codebook <- read_codebook("data1_codebook.csv",
         column_names = list(variable_levels = "Factor.Levels",
                             variable_original = "Old.Variable",
                             min = "Min", max = "Max"))
data1 <- readr::read_csv('data1-yr21.csv')
data1
non_valid <- validate_limits(data1, data1_codebook)

petebaker/codebookr documentation built on May 6, 2019, 12:05 a.m.