I want to generate a sequence where in a first step a random start number is chosen. Depending on the random start number (let's say: start_number = 3) I want to generate the following sequence. How can I do this?
seq_length <- 4
start_number <- sample(1:seq_length, 1, replace = TRUE)
# Desired sequence
int [1:100] 3 3 4 4 1 1 2 2 3 3 4 4 1 1 2 2 3 3 4 4 ...
You can use the
repetition function:if you want integers:
Edit:
Since you said your start is random, here is a code to do this: