Determine class of every input argument in R function -


consider having function, accepts number of arguments:

fun <- function(...) {     #/some code/    } 

how determine classes of input arguments 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") 

possibly this:

fun <- function(...) {   elipsis <- list(...)   print(sapply(elipsis, class))   ##/some code/   } 

however, must make sure passing in sensible thing. 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"  

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -