2

I have a data frame with several rows and I want to create a new data table with specific rows from the larger table. I want the new table to have only the rows where

(row number)%3 != 2

Basically, I want rows 1, 3, 4, 6, 7, 9, etc. Is there a simple way to do this? Perhaps using the subset operation?

Thanks!

user1015830
  • 111
  • 2
  • 11
  • square brackets or the `select` argument to the `subset` command. I strongly recommend reading the `Introduction to R`! http://mattgemmell.com/2008/12/08/what-have-you-tried/ – Ben Bolker Feb 26 '12 at 18:51

1 Answers1

6

If your data frame is df:

df[1:NROW(df) %% 3 != 2, ]
David Robinson
  • 77,383
  • 16
  • 167
  • 187