# Investigate the data set women, which is # part of base R. ?women # A. Use the function str() to list the class of the data set, # the number of observations and variables, along with # the variable names and types # B. List the first 10 lines of the data set # C. Write an R function to calculate BMI rounded to one decimal place value. # The formula for BMI is (weight / height^2)*703 # Use the function, round(), to round the calculated BMI # to one decimal place value ?round() # D. Test your BMI function: # for weight = 145 lbs, height = 64 inches (BMI should be 24.9) # for weight = 130 lbs, height = 66 (BMI should be 21) # E. Calculate the BMI for the women in the data set, women and # save these values in a new variable, bmi. # The new variable, bmi, should be a included as a new variable # in the data frame, women. # Check: Print the first and last 5 rows of the data frame, women # F. Use the summary() function to find the Minimum, Quartile 1 (Q1), # Median/Quartile 2 (Q2), Quartile 3 (Q3) and Maximum values of bmi # G. Convert the numeric variable, bmi, into the factor bmi.quartiles # using the function cut( ) and the following values as # breaks: Minimum, Quartile 1 (Q1), Median/Quartile 2 (Q2), # Quartile 3 (Q3), Maximum # The new variable, bmi.quartiles, should be included # as a new variable (column) in the women data frame # NOTE: Review Lecture 6 Class Notes - # Converting continuous variables to categorical variables ### IMPORTANT NOTE: Set the cut() function argument, include.lowest = TRUE ?cut() # CHECK: That the variable, bmi.quartiles, has been computed correctly and # added to the data frame, women # H. Use the table( ) function to generate # a frequency table for bmi.quartiles RSTUDIO
# Investigate the data set women, which is # part of base R. ?women # A. Use the function str() to list the class of the data set, # the number of observations and variables, along with # the variable names and types # B. List the first 10 lines of the data set # C. Write an R function to calculate BMI rounded to one decimal place value. # The formula for BMI is (weight / height^2)*703 # Use the function, round(), to round the calculated BMI # to one decimal place value ?round() # D. Test your BMI function: # for weight = 145 lbs, height = 64 inches (BMI should be 24.9) # for weight = 130 lbs, height = 66 (BMI should be 21) # E. Calculate the BMI for the women in the data set, women and # save these values in a new variable, bmi. # The new variable, bmi, should be a included as a new variable # in the data frame, women. # Check: Print the first and last 5 rows of the data frame, women # F. Use the summary() function to find the Minimum, Quartile 1 (Q1), # Median/Quartile 2 (Q2), Quartile 3 (Q3) and Maximum values of bmi # G. Convert the numeric variable, bmi, into the factor bmi.quartiles # using the function cut( ) and the following values as # breaks: Minimum, Quartile 1 (Q1), Median/Quartile 2 (Q2), # Quartile 3 (Q3), Maximum # The new variable, bmi.quartiles, should be included # as a new variable (column) in the women data frame # NOTE: Review Lecture 6 Class Notes - # Converting continuous variables to categorical variables ### IMPORTANT NOTE: Set the cut() function argument, include.lowest = TRUE ?cut() # CHECK: That the variable, bmi.quartiles, has been computed correctly and # added to the data frame, women # H. Use the table( ) function to generate # a frequency table for bmi.quartiles RSTUDIO
![](/static/compass_v2/shared-icons/check-mark.png)
- Use the str() function to get information about the women dataset
- Use head() function to display the first 10 rows of the women dataset
- Define a function to calculate BMI using the formula: (weight / height^2)*703, and round the result to one decimal place using the round() function
- Test the BMI function using two sets of weight and height values
- Calculate the BMI for each woman in the dataset and add it as a new variable, bmi, to the women dataset
- Use the summary() function to get basic statistical information about the bmi variable in the women dataset
- Convert the bmi variable to a factor variable, bmi.quartiles, using the cut() function and specified breaks, and add it as a new variable to the women dataset
- Use the table() function to get a frequency table for the bmi.quartiles variable in the women dataset.
Step by step
Solved in 4 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)