I need a column (y) added to my df, in which is repeated 8 times the "1", then 8 times the "2", then 8 times the "3", then 8 times the "4", etc.
It should be as long as the df is. See example output.
If the df does NOT have a length of a multiply of 8, the last repetitive numeric element does NOT have to be 8 times (see 3 times "5" in the example at the end).
I am amazed by people who get to apply such mathematics into a code. As a beginner in R with many years of experience in Excel, it is hard to get fealing of how to deal with such 'easy' repetations, where I would normally type the first part of the repetition in Excel and then just drag it down.
Although your code indeed works very well, I think I might have misargude my desired output.
In your code, after the final repetition of 8 times the value "8", it start again with 8 times the "1". While in fact, I would like it to continue with 8 times the "9", then 8 times the "10", then 8 times the "11", etc... till the end of the df.
And again: If the df does NOT have a length of a multiply of 8, the last repetitive numeric element does NOT have to be 8 times.