Re: [R] Help : delete at random

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed 02 Mar 2005 - 01:28:36 EST

On Tue, 01 Mar 2005 15:04:17 +0100, Caroline TRUNTZER <caroline.truntzer@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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Mar 02 02:20:41 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:38 EST