#데이터 프레임 생성
data <- rbind(
data.frame(value = usedcar[usedcar$model == "SEL", "price"], group = "sel"),
data.frame(value = usedcar[usedcar$model == "SE", "price"], group = "se"),
data.frame(value = usedcar[usedcar$model == "SES", "price"], group = "ses")
)
#바이올린 플롯 생성
ggplot(data, aes(x = group, y = value, fill = group)) +
geom_violin(trim = FALSE) +
geom_boxplot(width = 0.1, fill = "white") +
labs(title = "Violin Plot of Model", x = "Model",
y = "Price") + theme_minimal()
se : 가격이 낮고 분포도가 넓음 저렴한 가격대에 분포
sel : 가격이 가장 높고, 높은 가격에 이상치
ses : se다음으로 가격이 높고 분포도가 상대적으로 좁음 이상치 없음 가장 안정적