Question: ### Data Set - These data come from the [Centers for Disease Control and Prevention](www.cdc.gov) - To answer these questions you will need to use

### Data Set - These data come from the [Centers for Disease Control and Prevention](www.cdc.gov) - To answer these questions you will need to use the codebook on Brightspace, called `BRFSS_2021 Codebook`. For part 2 of the project, please note that not all of the variables listed in the codebook are included in the .csv file to be downloaded from Brightspace. - Download the `brfss2021.csv` file from Brightspace and place it in the same folder/directory as your script file. Then in RStudio, set your Working Directory to your Source File location: in the menus choose Session \| Set Working Directory \| To Source File Location. You most likely will see some warnings after it loads due to the fact that `read_csv()` will try to guess the column type but because there are so many rows it won't read enough of them to accurately make a guess. - You must use the `read_csv()` function when loading the .csv file. Do not use read.csv(). - Do not rename the .csv file that you download from Brightspace. - Do not edit the .csv file. ------------------------------------------------------------------------ ### Pipe Notation You may use the `tidyverse` pipe **`%>%`** or the new base R pipe **`|>`**. For a comparison, see [here](https://www.tidyverse.org/blog/2023/04/base-vs-magrittr-pipe/). ------------------------------------------------------------------------ ### Rounding Round all float/dbl values to two decimal places, unless otherwise noted. ------------------------------------------------------------------------ ### Preliminaries ```{r} rm(list = ls()) library(tidyverse) library(psych) library(lm.beta) # This will take a few moments to load since the file is so large. brf <- read_csv("brfss2021.csv", show_col_types = FALSE) ``` ------------------------------------------------------------------------ ## Questions ------------------------------------------------------------------------ ### Q4: Create a dataframe showing the number and the proportion of individuals who said their health is excellent, very good or good for each of the different lengths of times since last checkup. Store as a dataframe named `Q4`. Round to three decimal places. The percentage is out of the total number of observations for the `brf_part1` dataset. If your proportion does not match below, double check your Q2 cleaning. Hint: The 5x3 dataframe should look like this. The `[...]` is the name of the length of time variable. ``` [...] n proportion 1   2   3   4  0.038 8   ``` ```{r} ### Do not edit the following line. It is used by CodeGrade. # CG Q4 # ### TYPE YOUR CODE BELOW ### ### VIEW OUTPUT ### Q4 ``` ### Q5a: Now we will clean the variable that measures how often the respondent ate fruit per day or per week or per month. Create a new variable in `brf_part1` named `FRTDAY` that converts all of the responses into fruits eaten *per day*. Be sure to account for 0 days. Use 30 days per month, 7 days per week, and 0.02 for less than once a month in your conversion calculations. Place the new column as the first column in the dataframe. Make sure you added the new column FRTDAY to the existing `brf_part1` dataframe. The resulting dataframe should still have NAs for FRTDAY at this point. Hint: The resulting dataframe is 431,750 x 4. ```{r} ``` ### Q5b: Update the `FRTDAY` column in the dataframe `brf_part1` by removing the respondents who said "don't know/not sure" or refused to respond. Drop the original fruit variable from the `brf_part1` dataframe (but keep FRTDAY). Store the first 10 rows of the dataframe as `Q5.` Hint: The resulting dataframe is 422,747 x 3. Be sure the variables are in this order (left to right): FRTDAY, the length of time variable, then the general health variable. ```{r} ### Do not edit the following line. It is used by CodeGrade. # CG Q5 # ### TYPE YOUR CODE BELOW ### ### VIEW OUTPUT ### Q5 ``` 

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

Students Have Also Explored These Related Mathematics Questions!