tf_check: Check transform

Description Usage Arguments Details Value Examples

View source: R/tf_check.R View source: R/tf_check_2.R

Description

Check transformation values

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
tf_check(data, expr, key, ...)

## Default S3 method:
tf_check(data, expr, key, ...)

## S3 method for class 'atomic'
tf_check(data, expr, key, .all)

## S3 method for class 'data.frame'
tf_check(data, expr, key = TRUE, ...)

## S3 method for class 'tf_try'
tf_check(data, expr, key = TRUE, ...)

tf_pass(...)

## S3 method for class 'tf_check'
format(x, all = FALSE)

Arguments

data

table of data to function as environment for expr

expr

expression to evaluate

...

arguments to tf_check '

.all

logical whether to display all the observation or just the failed transformations. (Default: 'FALSEā€œ)

Details

format formats a tf_check object; argument all=TRUE will show all observations rather than those that fail'

Value

A data.table with the result of the expression followed by the names used from the columns

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
 
# Tables:
  
  data(iris) 
  setDT(iris)
  iris[ , Species := Species %>% as.character() ]

  iris %>% tf_check( Species %>% as.character() )
  iris %>% tf_check( Species %>% as.numeric()  )

  iris %>% setkey( Sepal.Length )
  iris %>% tf_check( Species %>% as.character(), .all=TRUE )
  
  iris %>% tf_pass( Species %>% as.character() )
  iris %>% tf_pass( Species %>% as.numeric()  )


x <- c(-2:2, NA) %>% 
  tf_try( sqrt ) %>% 
  tf_try( function(x) sqrt(x+1) ) 

tf_check(x)


Format: 
  

decisionpatterns/coercion documentation built on Nov. 4, 2019, 10:23 a.m.