I previously posted a question about how to randomly remove 20 consecutive values from a dataframe. I received an answer as follows:
df[-c(seq(sample(nrow(df) - 19, 1), length.out = 20)), ]
What I would now like to do however is to replace the randomly selected 20 consecutive values with NA, whilst retaining the same order of values in the dataframe.
Many thanks in advance.