R
ggvis 패키지를 이용한 산점도
이부일
2018. 7. 21. 07:35
install.packages("ggvis")
library(ggvis)
# 1. 기본
mtcars %>% ggvis(~mpg, ~wt) %>% layer_points()
# 2. 점의 색깔 변경하기
mtcars %>% ggvis(~mpg, ~wt, fill := "red") %>% layer_points()
# 3. 집단을 다른 색으로 표현하기
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars %>% ggvis(~mpg, ~wt, fill = ~cyl) %>% layer_points()
# 4. disp라는 양적 자료를 이용하여 채도를 반영하기
mtcars$cyl <- as.factor(mtcars$cyl)
mtcars %>% ggvis(~mpg, ~wt, fill = ~disp) %>% layer_points()