On Jul 9, 2011, at 7:02 PM, sven wrote:
Hello,
I am a student from Liverpool UK, working with some genetic data
using R.
I got a data.frame with about 250.000 rows and using a for loop to
delete
certain rows using the following code:
x <----- is a data.frame
x = x[-5,] ---> deletes row 5
x = x[-10,] ---> delets row 10
x = x[-i,] --> deletes row i
etc...
This takes ages for some reason. Isnt there a quicker way to do this?!
Two ways that would avoid repeated copying of medium size dataframes:
x <- x[-c(5,10, i) , ]
drpidx <- -c(5,10, i)
x <- x[-i, ]
--
David.
Cheers,
Sven
--
View this message in context:
http://r.789695.n4.nabble.com/Delete-row-takes-ages-alternative-tp3656949p3656949.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.