There are many ways to do it:
as some of them are either C++ function implemented through Rcpp or used by installing a package, I recommend you to use tail() as it's a built-in function and works with data frames too.
Hope this helps. Cheers...!!