Re: [R] Help : delete at random

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

On Tue, 01 Mar 2005 15:04:17 +0100, Caroline TRUNTZER <> wrote :

>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 mailing list PLEASE do read the posting guide! 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