I need to store the output into a separate vector so that I can plot the data (years against reproduction_rate). At the moment it only stores the final year and not years 1:20. Is there a way to use grep/regex to store the output values into one external vector instead of copying and pasting from the console.. Thank you !
>N<-1000
>years<-1:20
>storage<-()
for (year in years) {
reproduction_rate<-rnorm(n=1, mean=1, sd=0.4)+N
phrase<-paste("In year", year, "the population rate was", reproduction_rate)
print(paste("In year", year, "the population rate was",
reproduction_rate))
storage<-(reproduction_rate)
}
Aucun commentaire:
Enregistrer un commentaire