I would like to create a vector that repeats itself. (eg 1:3 until 12 rows)
1,2,3,1,2,3,1,2,3,1,2,3
How can I do this in R?
Thanks for your help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See
?rep. What you want is as easy asbut if you don’t know the length of the vector until run time but you do know the length of the output required, you could do (updated to reflect comment from @baptiste):