Question: title: Problem 2 - Visualization output: github_document --- ```{r setup, include=FALSE} library(tidyverse) library(readxl) library(patchwork) knitr::opts_chunk$set( echo = TRUE, warning = FALSE, message = FALSE, fig.width

title: "Problem 2 - Visualization" output: github_document --- ```{r setup, include=FALSE} library(tidyverse) library(readxl) library(patchwork) knitr::opts_chunk$set( echo = TRUE, warning = FALSE, message = FALSE, fig.width = 10, fig.asp = .6, out.width = "90%" ) theme_set(theme_minimal() + theme(legend.position = "bottom")) options( ggplot2.continuous.colour = "viridis", ggplot2.continuous.fill = "viridis" ) scale_colour_discrete = scale_colour_viridis_d scale_fill_discrete = scale_fill_viridis_d ``` ## Data Import and Preparation ```{r import_and_clean} # Import and clean data (same as Problem 1) posture_df = read_excel("p8105_mtp_data.xlsx", range = "A9:I1230") |> janitor::clean_names() |> mutate( age_group = case_when( !is.na(age_group) ~ age_group, age >= 18 & age <= 30 ~ "18-30", age >= 31 & age <= 40 ~ "31-40", age >= 41 & age <= 50 ~ "41-50", age >= 51 & age <= 60 ~ "51-60", age > 60 ~ ">60", TRUE ~ NA_character_ ), age_group = factor( age_group, levels = c("18-30", "31-40", "41-50", "51-60", ">60"), ordered = TRUE ), sex = factor(sex, levels = c("male", "female"))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock