I would like to complete the set.seed () scope after a certain line in order to have real randomization for the rest of the code. Here is an example where I want set.seed () to work for "rnorm" (line 4), but not for "nrow" (line 9)
set.seed(2014) f<-function(x){0.5*x+2} datax<-1:100 datay<-f(datax)+rnorm(100,0,5) daten<-data.frame(datax,datay) model<-lm(datay~datax) plot(datax,datay) abline(model) a<-daten[sample(nrow(daten),20),] points(a,col="red",pch=16) modela<-lm(a$datay~a$datax) abline(modela, col="red")
Thanks for the suggestions, really!
r random-seed
user3451767
source share