Remove nth row in R data frame?
r
Solution
There are a lot of diffrent ways to do that, a simple one is this:
# make an index eg. every 3th
ind <- seq(1, nrow(df), by=3)
# make subset --> this would choose every `ind` row
df[ind, ]
# --> this would exclude ale `ind` row
df[-ind, ]
hth
Problem
I have a data frame containing 1- minute measurements for things like humidity, soil temperatures, air temp, irradiance etc (14 Columns and about 35000 rows). I would like to remove every nth row so the sampling interval would be greater say 3o mins etc, this also speeds up the process when i join all the frames together to create a data frame for the year. Is there anyway I can have R automatically delete every nth row? without specifying each row number? This is a sample of the data frame. ``` V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 1 2012-11-01 00:00:00 24587 13.16 9.260 0.028 0.016 0.013 0.009 8.200 7.643 8.370 67.66 13.930 14.910 2 2012-11-01 00:01:00 24588 13.16 9.250 0.024 0.011 0.009 0.008 8.220 7.725 8.380 67.24 13.930 14.910 3 2012-11-01 00:02:00 24589 13.15 9.250 0.025 0.009 0.011 0.004 8.240 7.741 8.390 67.12 13.930 14.910 4 2012-11-01 00:03:00 24590 13.15 9.240 0.022 0.007 0.007 0.011 8.210 7.695 8.390 67.48 13.930 14.910 5 2012-11-01 00:04:00 24591 13.16 9.230 0.025 0.011 0.010 0.006 8.190 7.689 8.380 67.82 13.930 14.910 6 2012-11-01 00:05:00 24592 13.16 9.230 0.024 0.009 0.010 0.012 8.170 7.672 8.360 68.03 13.930 14.910 7 2012-11-01 00:06:00 24593 13.16 9.220 0.029 0.011 0.008 0.011 8.170 7.685 8.350 67.71 13.930 14.910 ``` Thanks!