library(ggplot2)
height <- c(170,168,174,175,188,165,165,190,173,168,159,170,184,155,165)
weight <- c(68,65,74,77,92,63,67,95,72,69,60,69,73,56,55)
plot(height,weight)

plot(weight~height)

ggplot(data = data.frame(height, weight), aes(x = height, y = weight)) + geom_point()

# 샘플 데이터 생성
set.seed(123) # 랜덤 시드 설정 (재현성을 위해)
x <- rnorm(100) # 랜덤한 x 값 생성
y <- 2 * x + rnorm(100) # y 값 생성 (x와 선형 관계에 노이즈 추가)
# 산점도 그리기
plot(x, y,
main="산점도 그래프", # 그래프 제목
xlab="X 축", # X 축 레이블
ylab="Y 축", # Y 축 레이블
pch=21, # 점 모양 (19는 십자 모양)
col="black" # 점 색상
)

# iris 데이터셋 로드
data(iris)
# 산점도 행렬 그리기
pairs(iris[, 1:4], # 숫자 변수(꽃잎과 꽃받침의 길이와 너비) 선택
main="Iris 데이터 산점도 행렬", # 그래프 제목
pch=21, # 점 모양 (filled circles)
bg=c("red", "green3", "blue")[unclass(iris$Species)], # 클래스별로 점 색상 지정
cex=2 # 점 크기
)

# 꽃의 종류(Species)에 따른 꽃잎 길이(Petal.Length) 상자그림
boxplot(Petal.Length ~ Species, data=iris,
main="꽃의 종류에 따른 꽃잎 길이 상자그림",
xlab="꽃의 종류", ylab="꽃잎 길이")

# 꽃의 종류(Species)에 따른 꽃잎 너비(Petal.Width) 상자그림
boxplot(Petal.Width ~ Species, data=iris,
main="꽃의 종류에 따른 꽃잎 너비 상자그림",
xlab="꽃의 종류", ylab="꽃잎 너비")
