Reputation: 5580
Consider having a function, that accepts any number of arguments:
FUN <- function(...) {
#/some code/
}
How to determine the classes of input arguments to this function FUN
?
library(ggplot2)
g <- qplot(mpg, wt, data = mtcars)
char <- "lalala"
DF <- data.frame(ch)
f <- function(x) x*x
FUN(g, char, DF, "DF", list(), f, `%in%`, NULL, TRUE, "TRUE")
Upvotes: 0
Views: 273
Reputation: 73265
Possibly this:
FUN <- function(...) {
elipsis <- list(...)
print(sapply(elipsis, class))
##/some code/
}
However, you must make sure you are passing in sensible thing. For example:
FUN("lalala", trees, "DF", list(), function(x) x * x, `%in%`, NULL, TRUE, "TRUE")
# [1] "character" "data.frame" "character" "list" "function"
# [6] "function" "NULL" "logical" "character"
Upvotes: 2