I am writing a pop simulation using R. The "growth" parameter in this simulation is sampled with probability p from two normal distributions with different means and sd. The code I am using to do so is the following:
R_0 <- sample(c(sample(rnorm(5000, mean = 3.5, sd = 0.7), 1),sample(rnorm(5000, mean = 1.5, sd = 0.3), 1)),1, prob = c(1 - p, p))
The two distributions correspond to a benign and stressful environment (B and S for simplicity). My problem is that later in the code I need to modify the growth rate R_0 according to a fixed quantity. This quantity depends on whether the R_0 coefficient was sampled from the B or the S environments. Is there a way to know from which of the two distributions R_0 is sampled?
I guess I could use and if else statement but I am not quite sure how to initialize it.
Thanks in advance.