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 frame is 'df' and you want to randomly delete 10 rows: df.new <- df[-sample(1:nrow(df), 10), ] The sample() function in this case randomly selects 10 values in the range 1:nrow(df). Using the '-' then removes these rows in the subsetting process, returning the new, smaller, data frame in df.new. See ?sample and ?Extract for more information. HTH, Marc Schwartz ______________________________________________ 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