0

I try to generate a series like:
a thousand of 1, a thousand of 2,... until a thousand of 100.
I try this code:

 test <- round(seq(1, 100, length.out=100000))

but unfortunately, when I do a table, I obtain this:
enter image description here

Have you an idea? Thanks a lot.

SRhm
  • 459
  • 1
  • 5
  • 11

3 Answers3

1

It's because you are using round which rounds to the nearest integer.

Just do test <- seq(1, 100, length.out=100000)

thc
  • 9,527
  • 1
  • 24
  • 39
1

You could just use:

test <- rep(1:100, each = 1000)
SmitM
  • 1,366
  • 1
  • 8
  • 14
0

What you need is replicate and not sequence:

replicate(10, c(1,2,3))

will generate 10 sequences of {1,2,3}:

     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    1    1    1    1    1    1    1    1    1     1
[2,]    2    2    2    2    2    2    2    2    2     2
[3,]    3    3    3    3    3    3    3    3    3     3

In your case, you would need:

replicate(1000, seq(1,100, by = 1)) 
Azim
  • 1,596
  • 18
  • 34