try_keep_txt {spectrolab} | R Documentation |
Wrap function to try to keep text
Description
Function operator returning a function f that tries to keep text.
Usage
try_keep_txt(f)
Arguments
f |
function to be applied |
Details
try_keep_txt
takes a function f as argument, typically a mathematical
operation such as mean, median, etc. and returns a modified version of it that
will try return a string of unique values in case function f emits a warning.
Useful when aggregating over spectral metadata that has both numeric values
(which you want to aggregate) and text values, which you want to keep.
Value
modified function f (f').
Author(s)
Jose Eduardo Meireles
Examples
library(spectrolab)
g = try_keep_txt(mean)
g(c(1, 2))
g(c("a", "b"))
[Package spectrolab version 0.0.19 Index]