ireturn {interfacer} | R Documentation |
Check a return parameter from a function
Description
This is intended to be used within a function to check the validity of a data
frame being returned from a function against an ispec
which is provided.
Usage
ireturn(df, iface, .prune = FALSE)
Arguments
df |
a dataframe - if missing then the first parameter of the calling function is assumed to be a dataframe. |
iface |
the interface specification that |
.prune |
get rid of excess columns that are not in the spec. |
Value
a dataframe based on df
with validity checks passed,
data-types coerced, and correct grouping applied to conform to iface
Examples
input = iface(col_in = integer ~ "an integer column" )
output = iface(col_out = integer ~ "an integer column" )
x = function(df = input, ...) {
df = ivalidate(...)
tmp = df %>% dplyr::rename(col_out = col_in)
ireturn(tmp, output)
}
x(tibble::tibble(col_in = c(1,2,3)))
output
[Package interfacer version 0.2.3 Index]