How to use function "sapply" with different variables in one function? For example, it is simple to use it with one variable, as is in the following example:
x1 <- c(1,2,3)
sapply(x1, function(x) dnorm(x, mean=2, sd=1))
However, how to apply different variables to some function with sapply? Please find the example below:
x1 <- c(1,2,3)
mean1 <- c(1,2,3)
sd1 <- c(1,2,3)
### ???
sapply( c(x1, mean1, sd1), function (x, mean, sd) dnorm(x = x1, mean = mean1, sd=sd1)
Thank you in advance.