I'm trying to make 4 objects with unique names that hold the output from multiple rbinom runs. Each set of rbinom runs uses different probabilities taken from a specific column of a different tibble. This is how I did it manually and I just want to recreate this with an iterative method.
collection_var_A <- rbinom(size = 20, n = 4 ,prob = (probs_tbl_A$value))
collection_var_B <- rbinom(size = 20, n = 4, prob = (probs_tbl_B$value))
collection_var_C <- rbinom(size = 20, n = 4, prob = (probs_tbl_C$value))
collection_var_D <- rbinom(size = 20, n = 4, prob = (probs_tbl_D$value))
The tibbles that contain the different $value columns look something like this:
probs_tbl_A <- tibble(
value = c(.56, .76, .85, .68), other = "other_stuff")
probs_tbl_B <- tibble(
value = c(.66, .72, .45, .39), other = "other_stuff")
probs_tbl_C <- tibble(
value = c(.56, .76, .85, .68), other = "other_stuff")
probs_tbl_D <- tibble(
value = c(.66, .72, .45, .39), other = "other_stuff")
I can get map() or map2() to iterate over the rbinom portion properly but it stores the output as a single list. I can't get it to iterate and simultaneously assign unique object names. I have tried supplying a list of the desired object names in different ways.
I feel like I'm missing a very easy way to do this.