구글문서를 읽고, 시트이름과 범위를 지정하여 변수(p601)에 지정한다. 평가할 자료가 세 개이면 세번 반복 !
> p601 <- read_sheet("https://docs.google.com/spreadsheets/d/1lbmUydP7NLYexEie9WfQuwDkjNtazmSRdA8YsdhiKEI/edit#gid=0", range="PAA-LAB-210601/3!B2:C40")
> p602 <- read_sheet("https://docs.google.com/spreadsheets/d/1lbmUydP7NLYexEie9WfQuwDkjNtazmSRdA8YsdhiKEI/edit#gid=0", range="PAA-LAB-210601/3!G2:H40")
> p603 <- read_sheet("https://docs.google.com/spreadsheets/d/1lbmUydP7NLYexEie9WfQuwDkjNtazmSRdA8YsdhiKEI/edit#gid=0", range="PAA-LAB-210601/3!L2:M40")
그래프를 Plot 함수를 이용하여 그린다.
> plot(p601$경과일, p601$`%`, xlab = "DAYS", ylab = "Conc(%)", ylim = c(3,5), xlim = c(0,360), main = "PAA Stability", col="red", type="b", pch=2, cex=1)
> par(new=T)
> plot(p602$경과일, p602$`%`, ann = F, axes = F ,ylim = c(3,5), xlim = c(0,360), col="blue", type="b", pch=1)
> par(new=T)
> plot(p603$경과일, p603$`%`, ann = F, axes = F ,ylim = c(3,5), xlim = c(0,360), col="black", type="b", pch=0)
* par(new=T) 를 이용하여 두번째, 세번째 데이터를 중복하여 그린다. 추가할 때마다 이 명령어를 사용해야 함.
레전드 추가
> legend("topright", legend = c("PAA-LAB-210601","PAA-LAB-210602","PAA-LAB-210603"), col = c("red","blue","black"), pch = c(2,1,0), inset = .02, box.lty = 0.8)
가로선 (상,하한 범위 그리기) 를 추가.
> abline(h=3.75, col="green", lty=2)
> abline(h=4.24, col="green", lty=2)
기타
회귀선을 그리려면 lm() 함수를 이용한 후 abline을 이용하여 추가.
> lm(p4$`%`~p4$경과일)
Call:
lm(formula = p4$`%` ~ p4$경과일)
Coefficients:
(Intercept) p4$경과일
4.0724839 -0.0002071
> m <- lm(p4$`%`~p4$경과일)
> abline(m, col="blue", lty=1)
[R 스크립트]
> plot(p601$경과일, p601$`%`, xlab = "DAYS", ylab = "Conc(ppm)", ylim = c(3,5), xlim = c(0,360), main = "PAA Stability", col="red", type="b", pch=2, cex=1)
> par(new=T)
> p1 <- plot(p602$경과일, p602$`%`, ann = F, axes = F ,ylim = c(3,5), xlim = c(0,360), col="blue", type="b", pch=1)
> par(new=T)
> plot(p603$경과일, p603$`%`, ann = F, axes = F ,ylim = c(3,5), xlim = c(0,360), col="black", type="b", pch=0)
> legend("topright", legend = c("PAA-LAB-210601","PAA-LAB-210602","PAA-LAB-210603"), col = c("red","blue","black"), pch = c(2,1,0), inset = .02, box.lty = 0.8)
> abline(h=4.24, col="green", lty=2)
> abline(h=3.75, col="green", lty=2)