select all the ol in a df exept the last 2 in r

To select all the 'ol' except the last 2 in a data frame, you can use the slice() function. Combine it with n() which provides the number of rows of the data frame and pass a sequence of the number of rows you'd like to keep. Here's an example using the dplyr package:

main.r
library(dplyr)

df %>%
  slice(1:(n() - 2))
44 chars
5 lines

This will select all rows from df except the last two.

gistlibby LogSnag