library(tidyverse)
mydata <- mtcars %>%
as_tibble(rownames = "model") %>%
select(model, wt, qsec) %>%
tail(8) %>%
pivot_longer(-model, names_to = "metric", values_to = "value") %>%
group_by(metric) %>%
mutate(rank = dense_rank(-value),
maxval=max(value)*1.05) %>%
ungroup()
mydata %>%
ggplot() +
aes(value, model) +
geom_col(alpha = .5) +
geom_text(aes(x=maxval/10,label = value)) +
geom_label(aes(x = maxval,label = rank)) +
facet_wrap(~metric, scales = "free_x") +
theme_minimal()