Commit bf0092d1 authored by Thomas Schwarzl's avatar Thomas Schwarzl

Add new file

parent 8c82bce8
# load(url("http://www-huber.embl.de/users/klaus/BasicR/bodyfat.rda"))
# 1. make sure your bodyfat data frame has the "bmi" column
# 2. Is there a correlation between bmi & wrist.circum
# 3. create a new variable that indicates the category of each person's BMI.
# Here are the categories
# Underweight: BMI is 0 to 18.5.
# Normal weight: BMI is 18.5 to 24.9.
# Overweight: BMI is 25 to 29.9.
# Obese: BMI is 30 to 100
# Anything over 100 is very unusual
# To do this, check out the cut() function.
# If the built-in R help isn't clear, try googling: "R cut() examples"
# 4. what is the average wrist.circum for each bmi category?
# 5. do you have an NA in your data? can you figure out why?
bf <- bodyfat %>%
mutate(bmi = (weight*0.454) / (height*.0254)^2) %>%
mutate(bmiCat = cut(bmi,breaks = c(0,18.5,24.9,29.9,100),labels = c("under","normal","over","obese"))) %>%
group_by(bmiCat) %>%
summarise(meanWrist = mean(wrist.circum))
#https://www.r-bloggers.com/from-continuous-to-categorical/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment