Description Usage Format Source Examples
The raw data behind the story "How Baby Boomers Get High" https://fivethirtyeight.com/features/how-baby-boomers-get-high/. It covers usage of 13 drugs in the past 12 months across 17 age groups.
1 |
A data frame with 17 rows representing age groups and 28 variables:
Age group
Number of people surveyed
Percentage who used alcohol
Median number of times a user used alcohol
Percentage who used marijuana
Median number of times a user used marijuana
Percentage who used cocaine
Median number of times a user used cocaine
Percentage who used crack
Median number of times a user used crack
Percentage who used heroin
Median number of times a user used heroin
Percentage who used hallucinogens
Median number of times a user used hallucinogens
Percentage who used inhalants
Median number of times a user used inhalants
Percentage who used pain relievers
Median number of times a user used pain relievers
Percentage who used oxycontin
Median number of times a user used oxycontin
Percentage who used tranquilizer
Median number of times a user used tranquilizer
Percentage who used stimulants
Median number of times a user used stimulants
Percentage who used meth
Median number of times a user used meth
Percentage who used sedatives
Median number of times a user used sedatives
National Survey on Drug Use and Health from the Substance Abuse and Mental Health Data Archive https://www.icpsr.umich.edu/icpsrweb/content/SAMHDA/index.html.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # To convert data frame to tidy data (long) format, run:
library(dplyr)
library(tidyr)
library(stringr)
use <- drug_use %>%
select(age, n, ends_with("_use")) %>%
pivot_longer(-c(age, n), names_to = "drug", values_to = "use") %>%
mutate(drug = str_sub(drug, start=1, end=-5))
freq <- drug_use %>%
select(age, n, ends_with("_freq")) %>%
pivot_longer(-c(age, n), names_to = "drug", values_to = "freq") %>%
mutate(drug = str_sub(drug, start=1, end=-6))
drug_use_tidy <- left_join(x=use, y=freq, by = c("age", "n", "drug")) %>%
arrange(age)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.