Here is an example:
This line of code repeats each subject specified twice:
subject <- rep(c("maths", "english", "science"), each = 2)
So output in the console for "subject" is:
# [1] "maths" "maths" "english" "english" "science" "science"
How can I adjust my code to make a minor change to the vector which is repeated? I would like the variable "subject" to produce the following when run:
"maths.A" "maths.B" "english.A" "english.B" "science.A" "science.B"
This would be very useful when generating a lot of data. Entering the names manually would be very inefficient.
I'm not sure if there is a way to do this, but any ideas are welcome :)