I often get in the situation where I have an index vector and a data object and I need to :
- slice data, if it's a data.frame
- indexing data, if it's a vector or list
I was wondering, is there already a function doing that in base R or tidyverse ? Because it bothers me to reimplement it in each of my projetcs, and I'm quite sure I'm not the only one who needs it.
If this function is not already available, I think it would be nice to extend dplyr::slice to handle vectors and lists (by indexing them). What do you think about it ?