Guest User

Untitled

a guest
Jan 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. x <- unlist(replicate(360, 1:sample(30, 1)))
  2.  
  3. x <- x # x repeats 360 times
  4. y <- rep( 1:3, times = x ) # y repeats x times
  5. z <- rep( 1:120, times = x ) # z repeats x times
  6.  
  7. x: 1 2 3 4 5
  8. y: 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
  9. z: 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
  10. x: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  11. 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’)
  12. 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’)
  13. x: 1 2 3 4 5 6 7 8 9 10 11 12 13
  14. y: 3 3 3 3 3 3 3 3 3 3 3 3 3 (number 3 repeats for the length of ‘x’)
  15. z: 1 1 1 1 1 1 1 1 1 1 1 1 1 (number 1 repeats for the length of ‘x’)
  16. x: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  17. 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
  18. the ‘y’ variable restarted)
  19. 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
  20. variable ‘z’ moves on to number 2 for the length of ‘x’)
  21. x: 1 2 3
  22. y: 2 2 2 (number 2 repeats for the length of ‘x’)
  23. z: 2 2 2 (number 2 repeats for the length of ‘x’)
  24. 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
  25. 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
  26. length of ‘x’)
  27. 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
  28. length of ‘x’)
  29. x: 1 2
  30. y: 1 1 (here variable ‘y’ restarts again, we repeat number ‘1’ for the length
  31. of x)
  32. z: 3 3 (since ‘y’ restarted, ‘z’ moves on to 3)
Add Comment
Please, Sign In to add comment