This function transforms the specified factor variable within a dataframe to lump all but the top n most frequent levels into an 'Other' category and then computes the count of each level.
Value
A dataframe showing the count of each level including 'Other' for all lumped lesser categories.
Details
This function leverages `dplyr` for data manipulation and `forcats` for managing factor levels. It is particularly useful in data summarization where the focus is on the most frequent categories.
Examples
# \donttest{
if(interactive()){
data <- data.frame(color = c("red", "blue", "green", "blue", "blue", "red", "yellow", "red"))
print(tar_count_top(data, color, n = 2))
}
# }
