I am kind of new to R and I would like to test different parameters to perform an Inverse Distance Weighting (IDW) interpolation.
data.idw.n <- idw(variable~1, data, data.grid, nmax=n)
I would like to repeat the following function several times, by just changing the n
value (let's say from 1
to 20
) of the nmax
variable and store the results separately to perform a model sensibility analysis.
I think i would need some kind of basic looping. Can someone help me?
Many thanks!
For this I would use mapply
:
list_of_idw_results = mapply(idw,
nmax = 1:20,
MoreArgs = list(formula = variable ~ 1,
data = data,
newdata = data.grid))
This leads to a list of idw
results, for nmax
values from 1 to 20. You can vary more variables at the same time by adding more variables after nmax = 20
.