[R] Help : delete at random

2005-03-01 Thread Caroline TRUNTZER
Hello I would like to delete some values at random in a data frame. Does anyone know how I could do? With best regards Caroline __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http:/

Re: [R] Help : delete at random

2005-03-01 Thread Sean Davis
Caroline, You probably want to look at ?sample. Use sample to choose the rows for deletion then use: df.new = df[-sampled,] Sean On Mar 1, 2005, at 9:04 AM, Caroline TRUNTZER wrote: Hello I would like to delete some values at random in a data frame. Does anyone know how I could do? With best regard

Re: [R] Help : delete at random

2005-03-01 Thread Marc Schwartz
On Tue, 2005-03-01 at 15:04 +0100, Caroline TRUNTZER wrote: > Hello > I would like to delete some values at random in a data frame. Does > anyone know how I could do? > With best regards > Caroline The basic process is to randomly select row indices from the possible number of rows. If your data

Re: [R] Help : delete at random

2005-03-01 Thread Uwe Ligges
Caroline TRUNTZER wrote: Hello I would like to delete some values at random in a data frame. Does anyone know how I could do? What about sample()-ing (if I understand "at random" correctly) a certain number of values from 1:nrow(data) and using the result as negative index the data.frame? Uwe Li

Re: [R] Help : delete at random

2005-03-01 Thread Duncan Murdoch
On Tue, 01 Mar 2005 15:04:17 +0100, Caroline TRUNTZER <[EMAIL PROTECTED]> 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

Re: [R] Help : delete at random

2005-03-01 Thread TEMPL Matthias
Best, Matthias > -Ursprüngliche Nachricht- > Von: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Im Auftrag von > Caroline TRUNTZER > Gesendet: Dienstag, 01. März 2005 15:04 > An: R-help@stat.math.ethz.ch > Betreff: [R] Help : delete at random > > > Hello > I woul

Re: [R] Help : delete at random

2005-03-01 Thread Adaikalavan Ramasamy
Might be slightly more interesting. If we want to generate values which are completely missing at random, then we can just simply sample all available index of a 2-d array. # simulate data # set.seed(1) # for reproducibility m <- matrix( rnorm(12), nr=4, nc=3 ) m [,1] [,2]