Assume that we want to run an sapply
or lapply
in R and the function was multiple parameters. Then we can define what is the parameter that we want to apply the sapply and to assign fixed values to the rest:
# this is the function like a linear equation # of the form y= a + b * x my_func<- function(a,b,c) { a+b*c } # the values of the x x = c(1,5,10) # we set a=1 and b=2 sapply(x,my_func,a=1, b=2)
[1] 3 11 21