1

I have this huge data set

enter image description here

and wanted to select the row every 16 days. I tried with dplyr but could not get it to work.

3 Answers3

2

We can use seq

 df[seq(1, nrow(df), by = 16),]
akrun
  • 874,273
  • 37
  • 540
  • 662
1

To select every 16th row, you can do:

df[seq(nrow(df)) %% 16 == 1,]

This will filter your data frame so it only contains row 1, row 17, row 33, row 49, etc

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
0

Or using filter

library(dplyr)
df %>%
  filter(row_number() %% 16 == 1)
Agaz Wani
  • 5,514
  • 8
  • 42
  • 62