R/extract_six_from_col.R

Defines functions extract_six_from_col

Documented in extract_six_from_col

# Generated by fusen: do not edit by hand

#' extract_six_from_col A function to sort decreasing and extract the first 6 elements of a given column
#' @param dataset  dataset given to extract a column from (type = tibble, data.frame)
#' @param column column to sort and extract the first 6 elements from (type = numeric, character)
#' @importFrom dplyr select all_of pull slice_head
#' @importFrom tibble tibble
#' @return A data frame when the column is numeric
#' @export
#'
#' @examples
#' extract_six_from_col(dataset = datasets::mtcars, column = "mpg")
#' extract_six_from_col(squirrels, "lat") 
extract_six_from_col <- function(dataset = datasets::mtcars, column = "mpg"){
  dataset %>%
    select(all_of(column)) %>%
    pull() %>%
    sort(decreasing = TRUE) %>%
    tibble() %>%
    slice_head(n = 6) %>%
    pull()
}
findanna/data.anna documentation built on May 6, 2022, 12:25 a.m.