imapper {interfacer} | R Documentation |
Specify mappings that can make dataframes compatible with an iface
specification
Description
When a function uses ivalidate()
internally to check a dataframe conforms to
the input it can attempt to rescue an incorrectly formatted dataframe.
This is a pretty advanced idea and is not generally recommended.
Usage
imapper(...)
Arguments
... |
a set of |
Details
This function is expected to be used only in the context of a .imap = imapper(...)
parameter to an ivalidate()
call to make sure that certain columns are present
or are a set value. Anything provided here will overwrite existing
dataframe columns and its use is likely to make function behaviour obtuse.
It may be deprecated in the future. The ...
input expressions should almost certainly
check for the values already existing before overwriting them.
If you are considering using this for replacing missing values check using
the default(...)
iface
type definition instead.
Value
a set of mappings
Examples
x = function(df = iface(col1 = integer ~ "an integer column" ), ...) {
df = ivalidate(df,...)
}
input=tibble::tibble(col2 = c(1,2,3))
# This fails because col1 is missing
try(x(input))
# This fixes it for this input
x(input, .imap=imapper(col1 = col2))