Hi there,

I have a vector of some functions e.g.
#-----------------------------#
f.1 <- function(a) {
  return( a );
}
f.2 <- function(a) {
  return( 1 - (tanh(a))^2 );
}
f.3 <- function(a) {
  return( 1 / (1+exp(-a)) * (1 - (1 / (1+exp(-a)))) );
}

func.l <- c(f.1, f.2, f.3); 
#-----------------------------#

and would like to calculate the output value of a function in the
vector, that is, pick e.g. function at position 2 in func.l and calculate the
output value for a=42.

func.l[2](42); # gives error

f <- func.l[2];
f(42); # gives error

Is there an easy way to solve this problem?

Cheers,
 Thomas

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to