strict (version 0.0.0.9000)

strict_sapply: Strict version of `sapply()`

Description

`sapply()` is dangerous for programmatic usage because it is type-unstable: you can't predict in advance what it's going to return just be reading the code. Instead use [vapply()], which has an additional argument `FUN.VALUE`, that

Usage

strict_sapply(...)

Arguments

...

Ignored

Examples

Run this code
# NOT RUN {
df <- data.frame(
 a = 1,
 b = "a",
 c = Sys.time(),
 d = ordered("a"),
 stringsAsFactors = FALSE
)

# A list
base::sapply(df, class)
# A matrix
base::sapply(df[3:4], class)
# A vector
base::sapply(df[1:2], class)
# }

Run the code above in your browser using DataLab