simple_hg.csv
0.00MB
challenger.csv
0.00MB

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 탄닌(영양제) 함유량과 애벌레 성장 간의 관계
advertising <- read.csv('c:/data/simple_hg.csv',header=T)
advertising
 
plot(input~cost,data=advertising,pch=21,col='blue',bg='red')
 
regression <- lm(input~cost,data=advertising)
 
abline(regression,col='pink')
title("광고비가 매출에 미치는 영향")
 
residual <- predict(regression,cost=cost)
residual
 
join <- function(i)
  lines(c(cost[i],cost[i]),c(input[i],yhat[i]), col="black")
sapply(1:length(residual),join)
cs

 

 

 


 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 온도가 O형링 파손수에 끼치는 영향
launch <- read.csv('c:/data/challenger.csv',header=T)
names(launch)
# distress_ct : O형링 파손수
# temperature : 온도
# field_check_pressure : 압력
# flight_num : 비행기 번호
 
 
# 회귀식 만들기
<- lm(distress_ct~temperature,launch)
#     y축          x축
# = lm(formula=distress_ct~temperature,data=launch)
 
 
# launch 데이터와 회귀식 그래프에서 보이기
plot(distress_ct~temperature,data=launch,col='red',bg='red',pch=21)
abline(m,col='blue')
title("온도가 O형링 파손에 미치는 영향")
cs

 

 

 

+ Recent posts