I need lapply to pass (to a function) values stored in a vector, successively.
values <- c(10,11,13,10)
lapply(foo,function(x) peakabif(x,npeaks=values))
So to get :
peakabif(x1,npeaks=10)
peakabif(x2,npeaks=11)
peakabif(x3,npeaks=13)
peakabif(x4,npeaks=10)
Is this possible or do I need to reconsider using lapply ? Is a for loop inside the function would work ?
You want to use mapply
for this: mapply(peakabif, x=foo, npeaks=values)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With