2

I have a table with an x and y value as follows:;

cbm <- captialbikedata %>%
    group_by(hr) %>%
    summarize(users = sum(registered))
x y
1 23
2 45

in this case how would I select 2? (I want to select the x value with the highest y value and then put it in a red file)

Christian
  • 35
  • 2

1 Answers1

0

We can use slice_max

library(dplyr)
red <- cbm %>%
    ungroup %>%
    slice_max(y) %>%
    pull(x)
akrun
  • 874,273
  • 37
  • 540
  • 662