Dear Posit Community,
I would like to discuss the functional difference, if any, between two functions: slice_head() from the dplyr package and head() from base R. Specifically, I am curious to know if there is a reason to prefer slice_head() over head() and similarly, slice_tail() over tail(). To illustrate, consider the following R code:
library(dplyr)
identical(
slice_head(starwars, n = 5),
head(starwars, n = 5)
)
identical(
slice_tail(starwars, n = 5),
tail(starwars, n = 5)
)
Both calls to the identical() function return TRUE, indicating that the outputs of slice_head() and head() as well as slice_tail() and tail() are identical. This leads me to question whether the slice_ prefix serves any purpose other than adding six extra characters. Is the only reason for slice_head() to adhere to the tidyverse naming convention, where functions are typically named as verbal phrases? Or is there a functional distinction between slice_head() and head()?
I would greatly appreciate your insights on this matter.
Thank you in advance for your response.
Best regards,
Michael