I've been reading another question about how to randomly subset rows of a dataframe, but I'm trouble figuring out how to change the values of a particular column in the dataframe for a random subset of the rows.
from Sample random rows in dataframe :
df = data.frame(matrix(rnorm(20), nrow=10))
df[sample(nrow(df), 3), ]
How do I replace randomly selected rows of the X1 column with 0's, for instance?
Thanks!