Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x <- unlist(replicate(360, 1:sample(30, 1)))
- x <- x # x repeats 360 times
- y <- rep( 1:3, times = x ) # y repeats x times
- z <- rep( 1:120, times = x ) # z repeats x times
- x: 1 2 3 4 5
- y: 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
- z: 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
- x: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
- y: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 (number 2 repeats for the length of ‘x’)
- z: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
- x: 1 2 3 4 5 6 7 8 9 10 11 12 13
- y: 3 3 3 3 3 3 3 3 3 3 3 3 3 (number 3 repeats for the length of ‘x’)
- z: 1 1 1 1 1 1 1 1 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
- x: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
- y: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 (here we repeat number 1 again, as
- the ‘y’ variable restarted)
- z: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 (variable ‘y’ restarted, so
- variable ‘z’ moves on to number 2 for the length of ‘x’)
- x: 1 2 3
- y: 2 2 2 (number 2 repeats for the length of ‘x’)
- z: 2 2 2 (number 2 repeats for the length of ‘x’)
- x: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
- y: 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 (number 3 repeats for the
- length of ‘x’)
- z: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 (number 1 repeats for the
- length of ‘x’)
- x: 1 2
- y: 1 1 (here variable ‘y’ restarts again, we repeat number ‘1’ for the length
- of x)
- z: 3 3 (since ‘y’ restarted, ‘z’ moves on to 3)
Add Comment
Please, Sign In to add comment