[R] Help : delete at random
Duncan Murdoch
murdoch at stats.uwo.ca
Tue Mar 1 15:28:36 CET 2005
On Tue, 01 Mar 2005 15:04:17 +0100, Caroline TRUNTZER
<caroline.truntzer at chu-lyon.fr> wrote :
>Hello
>I would like to delete some values at random in a data frame. Does
>anyone know how I could do?
Assuming your data.frame is named df:
To delete index i, use df[-i, ] (i.e. the row selection is the
negative of the index you don't want).
This works for vectors i, so df[-sample(1:N, n), ] would delete
a random selection of n rows from N.
Duncan Murdoch
More information about the R-help
mailing list