check_columns: Given a set of columns of data in a time series check whether...

Description Usage Arguments Details Value Examples

Description

It also emits the output of skimr::skim and a plot so that the user can also visually inspect additional aspects of the columns.

Usage

1
check_columns(data_, col_names)

Arguments

data_

The dataframe to check.

col_names

Character vector of columns to check.

Details

Note that the returned plot can be captured and modified further to, for example, change the X and Y limits.

Value

a ggplot2 object for the columns that were checked

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
data_that_passes <- data.frame(smk80 = c('never', 'past', 'never'),
                               smk82 = c('past', 'never', 'past'),
                               smk84 = c('never', 'never', 'past'))
data_that_fails <- data.frame(smk80 = c('never smoker', 'past smoker', 'never smoker'),
                              smk82 = c('past', 'never', 'past'),
                              smk84 = c('never', 'never', 'past'))
check_columns(data_that_passes, generate_column_names('smk', from = 1980, to = 1984))
## Not run: 

check_columns(data_that_fails, generate_column_names('smk', from = 1980, to = 1984))


## End(Not run)

# You can also capture the plot returned and modify it.
numeric_data_to_plot <- data.frame(
                           bmi80 = rnorm(200, mean = 30, sd = 3),
                           bmi82 = rnorm(200, mean = 31, sd = 2.8),
                           bmi84 = rnorm(200, mean = 32, sd = 2.5))
p <- check_columns(numeric_data_to_plot,
                   generate_column_names('bmi', from = 1980, to = 1984))
# Show default plot
p

# Modify default plot to zoom in by changing the limits
library(ggplot2)
p + ylim(27, 35)

# Modify the default plot to invert the X and Y axes and use
# a different theme.
p + coord_flip() + theme_minimal()

nurseshealthstudy/Nurses documentation built on May 14, 2019, 3:08 a.m.