I was wondering how I could generate 1000 integers from 1 to 1000, one at a time in R. Making this a function, this means on the first run of the function, the function should produce 1
, the second run 2
, on the third run 3
, ... 1000
?
I have tried the following in R with no success:
gen = function(n){
sample(1:n, 1, replace = FALSE)
}
gen(1000)