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
  • 789,025
  • 32
  • 460
  • 575
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
  • 91,771
  • 6
  • 28
  • 55
0

Or using filter

library(dplyr)
df %>%
  filter(row_number() %% 16 == 1)
Agaz Wani
  • 5,080
  • 7
  • 41
  • 58