2

I would like to evaluate a certain function g inside of a function f, but the arguments of g are given to f in a list. f and g are defined in this way:

g <- function(a,b){
  a+b
}
f <- function(x, y, l){
  # do some stuff on x and y
  z <- g(l)  # Not working
  # do some stuff on x, y and z
}

I would like to run f in this way:

f(xx, yy, list(a=aa, b=bb)

where aa, bb, xx, yy are some R objects.

How could I do that?

0

1 Answer 1

2

You should use do.call function in this way:

f <- function(x, y, l){
  # do some stuff on x and y
  z <- do.call(g,l)
  # do some stuff on x, y and z
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.