I have a data frame with the following dimensions 217 x 5 I want to create two data frames from the original. 1) One containing every tenth row of the original data frame 2) Other containing the rest of the rows. How do I do this? I've tried subset() and calling the index. thank you in advance, [[alternative HTML version deleted]]
try this: (if d is the data.frame) 1) d[ (1:217)[1:217 %% 10 == 0], ] 2) d[ (1:217)[1:217 %% 10 != 0], ] 2005/11/21, mark salsburg <mark.salsburg at gmail.com>:> I have a data frame with the following dimensions 217 x 5 > > I want to create two data frames from the original. > > 1) One containing every tenth row of the original data frame > 2) Other containing the rest of the rows. > > How do I do this? I've tried subset() and calling the index. > > thank you in advance, > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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 >
Hi use selection <- seq(10, final length, 10) or selection <- (1:n)*10 and mydf[selection,] mydf[-selection,] HTH Petr On 21 Nov 2005 at 15:37, mark salsburg wrote: Date sent: Mon, 21 Nov 2005 15:37:28 -0500 From: mark salsburg <mark.salsburg at gmail.com> To: R-help at stat.math.ethz.ch, r-help at stat.math.ethz.ch Subject: [R] Removing Rows> I have a data frame with the following dimensions 217 x 5 > > I want to create two data frames from the original. > > 1) One containing every tenth row of the original data frame > 2) Other containing the rest of the rows. > > How do I do this? I've tried subset() and calling the index. > > thank you in advance, > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.htmlPetr Pikal petr.pikal at precheza.cz