# 상관분석 — cars 산점도와 피어슨 상관 출력 함께 읽기
# 적용 범위: 공식 cor.test()의 피어슨 검정 기능을 R 기본 cars 데이터에 적용한 응용 예제입니다. 원문의 Examples에 실린 동일 데이터 조합을 재현한 것은 아닙니다.
# 출처: https://stat.ethz.ch/R-manual/R-patched/library/stats/html/cor.test.html
# 출처: https://stat.ethz.ch/R-manual/R-patched/library/datasets/html/cars.html
# 실행 확인 환경: R version 4.6.2 (2026-10-29)
# 아래 코드를 실행하면 출력과 그림을 확인할 수 있습니다.

# 재현 설정: 같은 난수 방식과 출력 자릿수를 사용합니다.
RNGkind("Mersenne-Twister", "Inversion", "Rejection")
set.seed(2026)
options(width = 90, digits = 7, scipen = 7)

test <- cor.test(cars$speed, cars$dist, method = "pearson")
test
plot(cars$speed, cars$dist, pch = 19, col = "#2563EB",
     main = "속도와 정지거리의 상관", xlab = "속도(mph)", ylab = "정지거리(ft)")
