ropensci / NLMR

📦 R package to simulate neutral landscape models 🏔
https://ropensci.github.io/NLMR/
65 stars 17 forks source link

`user_seed` parameter for `nlm_mpd` #83

Open bniebuhr opened 2 years ago

bniebuhr commented 2 years ago

Is it possible to include a user_seed parameter for nlm_mpd, in a way similar to, e.g., nlm_gaussianfield or nlm_fbm? This would be useful to create the very same landscapes with different degrees of clumpiness.

bniebuhr commented 2 years ago

So far I have explored that doing this trick:

# function with user_seed
nlm_mpd_seed <- function(user_seed = 123, ...) {
  set.seed(user_seed)
  NLMR::nlm_mpd(...)
}

# parameters
param_df <- expand.grid(ncol = 100,
                        nrow = 100,
                        resolution = 100, 
                        roughness = c(seq(0.1, 1, 0.1), 2), #0.5,
                        rand_dev = 1 #c(0.1, 1, 5, 10, 100)
                        ) %>% 
  tibble::as_tibble()

# simulated landscapes
nlm_list = param_df %>% pmap(nlm_mpd_seed, user_seed = 123)

# plot
landscapetools::show_landscape(nlm_list)

but it would be nice to have it within the function.