Commit e05d410f authored by Thea Van Rossum's avatar Thea Van Rossum

Update extraChallenge.R

parent 8d5eb06d
# 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
# 1. create a new column in your data called "bmi" using this formula:
# bmi = (weight*0.454) / (height*.0254)^2
# 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.
......@@ -15,11 +16,6 @@
# 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