Description Usage Arguments Examples
Sometimes when you have a lot of results you want to show a short version of the results with an "Other..." category. This function performs a summarisation and allows you to specify the number of rows you want and something to sort the rows by. It will then give you strictly the top n results (ignoring ties) and group all the other results into a single summary row entitled "Other..."
1 | summariseTopN(df, n, sortVar, label = "Other...", ...)
|
df |
- a grouped df - there must be some grouping for the summarise to return more than one row. |
n |
the number of rows to keep - the result will have one more row than this |
sortVar |
- the column containing the variable to sort by (syntax as in arrange(...)) |
label |
- the name of the "Other..." row |
... |
- the arguments to the dplyr summarise(...) |
1 | diamonds %>% group_by(clarity) %>% summariseTopN(n=5, sortVar = desc(count), count = n(), avPrice = mean(price))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.