UPDATE: dplyr has been updated since this question was asked and now performs as the OP wanted
I´m trying to get the second to the seventh line in a data.frame
using dplyr
.
I´m doing this:
require(dplyr)
df <- data.frame(id = 1:10, var = runif(10))
df <- df %>% filter(row_number() <= 7, row_number() >= 2)
But this throws an error.
Error in rank(x, ties.method = "first") :
argument "x" is missing, with no default
I know i could easily make:
df <- df %>% mutate(rn = row_number()) %>% filter(rn <= 7, rn >= 2)
But I would like to understand why my first try is not working.