The function vswitch is a vectorized version of base::switch() optimized for performance.

vswitch(EXPR, ...)

Arguments

EXPR

an expression evaluating to a number or a character string.

...

the list of alternatives. If it is intended that EXPR has a character-string value these will be named, perhaps except for one alternative to be used as a ‘default’ value.

Value

The value of one of the elements of ..., or NA whenever no element is selected. Contrary to base::switch() the result is always visible.

Details

Only the EXPR argument is treated as a vector. In particular, if any of the alternatives (or the default alternative) is a vector, the result will be a list of vectors.

See also

Other deprecated functions: coalesce.na-deprecated, df_to_list-deprecated, hms.to.seconds-deprecated, kimisc-deprecated, list_to_df-deprecated, nc-deprecated, nlist-deprecated, ofactor-deprecated, sample.rows-deprecated, seconds.to.hms-deprecated, thisfile-deprecated, tll-deprecated