epi_clean_cond_numeric: Check whether column type is integer or numeric

Description Usage Arguments Value Author(s) See Also Examples

View source: R/epi_clean_cond_numeric.R

Description

Check if column is integer or numeric (TRUE). Useful when extracting columns from a large data frame using dplyr (ie get all integer and numeric columns)

Usage

1

Arguments

col

column header. This will be passed to is.integer(col) and is.numeric(col)

Value

boolean TRUE/FALSE indicating whether column passed is type integer or numeric

Author(s)

Antonio Berlanga-Taylor <https://github.com/AntonioJBT/episcout>

See Also

epi_clean_cond_chr_fct, epi_clean_cond_date, epi_clean_class_to_factor, epi_clean_count_classes, is.integer, is.numeric

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
set.seed(12345)
n <- 20
df <- data.frame(
  var_id = rep(1:(n / 2), each = 2),
  var_to_rep = rep(c('Pre', 'Post'), n / 2),
  x = rnorm(n),
  y = rbinom(n, 1, 0.50),
  z = rpois(n, 2)
)
df %>% select_if(~ epi_clean_cond_numeric(.))
epi_clean_cond_numeric(df[[2]]) # should be FALSE
epi_clean_cond_numeric(df[, 'x']) # should be TRUE

## End(Not run)

AntonioJBT/episcout documentation built on Nov. 7, 2019, 5:34 p.m.