Hello Guys! I am wondering about below function which automatically simulates random numbers - given below that manual calculation too. Anyone help me to fix that error. I got that error "object of type 'closure' is not subsettable" So Do you have any ideas?
Regards Mayooran #########Manual calculation########## N <- 1e7 n <- 8 indx <- 1:N start1 <- sort(sample(indx,1)) start2 <- sort(sample(start1+1,1)) start3 <- sort(sample(start2+1,1)) start4 <- sort(sample(start3+1,1)) start5 <- sort(sample(start4+1,1)) start6 <- sort(sample(start5+1,1)) start7 <- sort(sample(start6+1,1)) start8 <- sort(sample(start7+1,1)) start1 start2 start3 start4 start5 start6 start7 start8 ###########Common function############# start<-function(n){ indx <- 1:N for (i in 1:n) { if (i<2) { start[i] <- sort(sample(indx,1)) } else { start[i] <- sort(sample(start[i-1]+1,1)) } } } start(8) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.