Let's say I have the following data frame
weight <- c(100, 137, 158, 225, 149)
age <- c(15, 18, 21, 31, 65)
gender <- c("Female, "Male, "Male", "Male", "Female")
table <- data.frame(weight, age, gender)
If I wanted to do a linear regression to see how weight predicts age, as well as examine it, I'd do:
allData <- lm(age ~ weight, data = table)
summary(allData)
What do I do if I wanted to examine how weight predicts age for females only? As in, use only the female data population to see how weight predicts age? I'm thinking something like:
FemaleData <- lm(age ~ weight, data=table (gender="Female"))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…