I'm new to R and while practicing I couldn't work out how to create a vector whose outcome is :
red yellow blue yellow blue green blue green magenta green magenta cyan .
I noticed that
rep(seq(1:3),times=4) + rep(0:3, each=3)
[1] 1 2 3 2 3 4 3 4 5 4 5 6
so I thought it cold be useful to create a vector such as
colors <- c("red", "yellow", "blue","green","magenta","cyan")
and associate its values to the sequence but then I don't know how to go on.
Thank you in advance for any help!
rep
value is the indexcolors[rep(seq(1:3),times=4) + rep(0:3, each=3)]
– akrun