Week 1 - Homework
Write your code directly in a Quarto document.
To create a Quarto document: go to File -> New File -> Quarto Document, then click Create.
- Import the data file “visceral_fat.csv”.
- First, download the
visceral_fat.csvfile via this link. - Then, upload the file to a folder of your choice within your RStudio project.
- Next, import the data into RStudio and name the data frame
visceral_fat.
Tip:
Use the click-button method in RStudio to upload and import the file. Then, copy and paste the R commands generated into a code chunk in your Quarto report.
Once imported, you can use the visceral_fat dataset for further analysis in your report.
- Summarize the dataset.
Run the function summary(visceral_fat) to generate a summary of the dataset. Describe what information you obtained.
- Draw a histogram.
Create a histogram for the diastolic blood pressure using the column visceral_fat[["diastolic_bp__mmhg"]]. Describe what you observe from the plot.
- Handle an outlier.
After consulting with a clinician, you discover that the 27th value of the diastolic blood pressure was incorrectly recorded.
- Ignore this value using
visceral_fat[["diastolic_bp__mmhg"]][-27] - Redraw the histogram after excluding the outlier and describe any changes you observe.
- Compare mean and median.
Calculate the mean (mean()) and the median (median()) for the diastolic blood pressure
- before ignoring the 27th value:
visceral_fat[["diastolic_bp__mmhg"]] - after ignoring the 27th value:
visceral_fat[["diastolic_bp__mmhg"]][-27]
Describe how the outlier affects the mean and median.
- Click “Render” to generate your Quarto report.
The homework correction is available here: link