# NOT RUN {
# To convert data frame to tidy data (long) format, run:
library(dplyr)
library(tidyr)
library(stringr)
drinks_tidy <- drinks %>%
pivot_longer(cols = ends_with("servings"), names_to = "type", values_to = "servings") %>%
mutate(
type = str_sub(type, start=1, end=-10)
) %>%
arrange(country, type)
# }
Run the code above in your browser using DataLab