I am currently programming a loop and have made a vector called 'growth_rate'. I want to use the rnorm function to draw a random number for this vector 20 times. The code I am using to do this is growth_rate<-rep((rnorm(n=1, mean=1, sd=0.4)), times = 20). I have also made a vector called >rate<-rnorm(n=1, mean=1, sd=0.4). Making a vector called >grate<-rep(rate, 20) it still outputs the same number 20 times instead of 20 random numbers eg [1] 1.304936 1.304936 1.304936 1.304936 1.304936 1.304936 1.304936 1.304936 1.304936 and so on...
. Is there anyway I can output 20 random numbers in one vector and not make 20 separate vectors using rnorm instead? Thank you!
Aucun commentaire:
Enregistrer un commentaire