Description Usage Arguments Details Value Examples
It also emits the output of skimr::skim and a plot so that the user can also visually inspect additional aspects of the columns.
1 | check_columns(data_, col_names)
|
data_ |
The dataframe to check. |
col_names |
Character vector of columns to check. |
Note that the returned plot can be captured and modified further to, for example, change the X and Y limits.
a ggplot2 object for the columns that were checked
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()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.