top_sites <- reactive({
sites_program() %>%
dplyr::group_by(time) %>%
dplyr::count(site)%>%
dplyr::top_frac(.5)
})I had a graph in a Shiny Application that had too many values and the values were getting scrunched up.
I determined to add a tab panel and display multiple views of the graph for ease of use.
I used top_frac function from the dplyr 📦.
My next dilemma was getting the bottom half. I used Chat-GPT and here is the transcript.
I was able to take the example and apply to my data set. This would have taken me hours to figure our prior to this assistance.
bottom_sites <- reactive({
bottom_frac <- 0.5
result <- sites_program() %>%
dplyr::group_by(time) %>%
dplyr::count(site)%>%
arrange(n) %>%
slice(1:floor(n() * bottom_frac))
})