Given a vector (actually a list) of functions:
fs = c(sin, cos, tan)
and a vector of values:
xs = c(.1, .3, .5)
Is there a better/neater/faster/stronger way of computing fs[[i]](xs[i])
for each vector element:
vapply(1:3, FUN.VALUE = 1 ,function(i){fs[[i]](xs[i])})
[1] 0.09983342 0.95533649 0.54630249
Or am I missing a fapply
function somewhere? The functions will always be functions of a single scalar value and returning a single scalar value.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…