-
Notifications
You must be signed in to change notification settings - Fork 0
/
Unit2G.R
32 lines (21 loc) · 1.04 KB
/
Unit2G.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
data(state)
stateData <- cbind(data.frame(state.x77), state.abb, state.area, state.center, state.division, state.name, state.region)
str(stateData)
plot(stateData$x, stateData$y)
tapply(stateData$HS.Grad, stateData$state.region, mean)
boxplot(stateData$Murder~stateData$state.region)
subset(stateData, state.region == "Northeast")
lifeExpModel <- lm(Life.Exp~Population + Income + Illiteracy + Murder + HS.Grad + Frost + Area, data = stateData)
summary(lifeExpModel)
plot(stateData$Income, stateData$Life.Exp)
lifeExpModel <- lm(Life.Exp~Population + Income + Illiteracy + Murder + HS.Grad + Frost, data = stateData)
summary(lifeExpModel)
lifeExpModel <- lm(Life.Exp~Population + Income + Murder + HS.Grad + Frost, data = stateData)
summary(lifeExpModel)
lifeExpModel <- lm(Life.Exp~Population + Murder + HS.Grad + Frost, data = stateData)
summary(lifeExpModel)
lifeExpPred <- predict(lifeExpModel)
sort(lifeExpPred)
stateData$state.name[which.min(stateData$Life.Exp)]
stateData$state.name[which.max(stateData$Life.Exp)]
sort(lifeExpModel$residuals)