strict_sapply | R Documentation |
sapply()
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
strict_sapply(...)
... |
Ignored |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.