This dataset tracks adult nutrition, physical activity, and weight status metrics derived from the CDC’s Behavioral Risk Factor Surveillance System (BRFSS). It provides national and state specific data broken down by demographic categories. It has 199k rows and 33 columns.
It has 7 quantitative variables:
YearStart, YearEnd, Data_Value, Data_Value_Alt, Low_Confidence_Limit, High_Confidence_Limit, and Sample_Size.
and 9 qualitative variables:
LocationAbbr, LocationDesc, Class, Topic, Question, Data_Value_Unit, Data_Value_Type, StratificationCategory1, and Stratification1
Rows: 118580 Columns: 33
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (26): LocationAbbr, LocationDesc, Datasource, Class, Topic, Question, Da...
dbl (6): YearStart, YearEnd, Data_Value, Data_Value_Alt, Low_Confidence_Lim...
num (1): Sample_Size
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#Looking at specfic varibles to answer 1st Visualization questionunique(health_df$Question)
[1] "Percent of adults aged 18 years and older who have obesity"
[2] "Percent of adults aged 18 years and older who have an overweight classification"
[3] "Percent of adults who achieve at least 150 minutes a week of moderate-intensity aerobic physical activity or 75 minutes a week of vigorous-intensity aerobic activity (or an equivalent combination)"
[4] "Percent of adults who achieve at least 150 minutes a week of moderate-intensity aerobic physical activity or 75 minutes a week of vigorous-intensity aerobic physical activity (or an equivalent combination) and engage in muscle-strengthening activities on 2 or more days a week"
[5] "Percent of adults who achieve more than 300 minutes a week of moderate-intensity aerobic physical activity or 150 minutes a week of vigorous-intensity aerobic activity (or an equivalent combination)"
[6] "Percent of adults who engage in muscle-strengthening activities on 2 or more days a week"
[7] "Percent of adults who engage in no leisure-time physical activity"
[8] "Percent of adults who report consuming fruit less than one time daily"
[9] "Percent of adults who report consuming vegetables less than one time daily"
#Checking specfic naming to use in visulationsunique(health_df$StratificationCategory1)
Filter data to obesity and income and order the income
obesity_income <- health_df |>filter(Question =='Percent of adults aged 18 years and older who have obesity'& StratificationCategory1 =='Income'& Stratification1 !='Data not reported'&!is.na(Data_Value)) |>arrange(desc(Data_Value))head(obesity_income)
ggplot(obesity_income, aes(x = Stratification1, y = Data_Value, fill = Stratification1)) +geom_bar(position ='dodge', stat ='identity') +scale_fill_manual(values =c('#318040', '#e76f51', '#666370', '#2b5c8f', '#D33E43', '#e9c46a')) +theme_light() +labs(title ='Adult Obesity by Income Level',x ='Income Level',y ='Percentage of Adults (%)',fill ='Income Level',caption ='Source: Centers for Disease Control and Prevention (CDC)' ) +theme(axis.text.x =element_text(angle =20, hjust =1) ) +scale_x_discrete(labels =function(x) str_wrap(x, width =5))# Cleans up x-axis label overlap
Does education level affect obesity rates?
Filtering obesity and education
# Filter data for education and obesitybox_data <- health_df %>%filter(Question =='Percent of adults aged 18 years and older who have obesity', StratificationCategory1 =='Education'&!is.na(Data_Value))
Creating the boxplot
ggplot(box_data, aes(x = Stratification1, y = Data_Value, fill = Stratification1)) +geom_boxplot() +scale_fill_manual(values =c('#3A7EC5', '#C5813A', '#92A45B', '#6D5BA4')) +theme_grey() +labs(title ='Adult Obesity Rates by Education Level',x ='Education Level',y ='Obesity Prevalence (%)',fill ='Education Level',caption ='Source: Centers for Disease Control and Prevention (CDC)' ) +theme(axis.text.x =element_text(angle =15, hjust =1) ) +scale_x_discrete(labels =function(x) str_wrap(x, width =5))