[R] Removing Rows

Henrik Bengtsson hb at maths.lth.se
Tue Nov 22 01:56:11 CET 2005


seq() is good at these kind of things:

keep <- seq(from=1, to=nrow(d), by=10)
d1 <- d[ keep,]
d2 <- d[-keep,]

/Henrik

Juan Pablo Romero wrote:
> 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
>>
> 
> 
> ______________________________________________
> 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
> 
>




More information about the R-help mailing list