r - How to pass a number of "x" arguments to a function that subset a data.frame and obtain "x" data.frames? -


i have question related applying different arguments in 1 function in order obtain different datasets.

i have created function takes data , filter it, according value of arguments in function (i haven't write full function becasue thought complicates more explanation of question).

the function looks this:

myfun (type, spp, incl){      #something subset data according     # type, spp, incl values, , gives output      # data frame called datanalyisis      datanalysis } 

if consider potential values function arguments are:

type <- c("1", "2", "3", "4") spp <- c( "spruce", "pine","birch") incl <- c("no", "yes") varoptions <- list(type, spp , incl) varoptions.grid <- expand.grid(varoptions) 

i 24 potential combination arguments values. goal use combination of argument values, obtained in "varoptions.grid", in function. , result should 24 different datasets.

i have tried this:

var1 <- as.vector(as.character(varoptions$var1)) var2 <- as.vector(as.character(varoptions$var2)) var3 <- as.vector(as.character(varoptions$var3))  finaldata <- mapply ("myfun", type =.var1, spp = .var2, incl=.var3)) 

i think obtaining huge array processes. believe missing understanding in how mapply works or using incorrect process solve problem.

if have input in how solve apreciate!, 3th day stuck in problem :(

thank time!


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -