더 보기 좋은 차트 만들기

R로 배우는 plotly 중급 인터랙티브 데이터 시각화

Adam Loy

Statistician, Carleton College

shiny 없이 앱 만들기

bscols 예시 애니메이션

R로 배우는 plotly 중급 인터랙티브 데이터 시각화

열 레이아웃을 위한 bscols()

library(plotly)
library(crosstalk)
shared_data <- world2014 %>% SharedData$new()

p1 <- shared_data %>% plot_ly(x=~income, y = ~co2, color = ~four_regions) %>% add_markers() %>% layout(xaxis = list(type = "log"), yaxis = list(type = "log")) p2 <- shared_data %>% plot_ly(x=~income, y = ~life_expectancy, color = ~four_regions) %>% add_markers() %>% layout(xaxis = list(type = "log")))
bscols(p1, p2)
R로 배우는 plotly 중급 인터랙티브 데이터 시각화

열 레이아웃을 위한 bscols()

bscols 단계별 애니메이션 1

R로 배우는 plotly 중급 인터랙티브 데이터 시각화

필터 추가: 체크박스

체크박스가 있는 bscols 애니메이션

bscols(filter_checkbox(id = "four_regions", label = "Region", 
                       sharedData = shared_data, group = ~four_regions),
       p1)
R로 배우는 plotly 중급 인터랙티브 데이터 시각화

필터 추가: 선택 상자

선택 상자가 있는 bscols 애니메이션

bscols(filter_select(id = "four_regions", label = "Region", 
                sharedData = shared_data, group = ~four_regions),
       p1)
R로 배우는 plotly 중급 인터랙티브 데이터 시각화

필터 추가: 슬라이더

슬라이더가 있는 bscols 애니메이션

bscols(filter_slider(id = "co2", label = "CO2 concentrations", 
                     sharedData = shared_data, column = ~co2),
       p1)
R로 배우는 plotly 중급 인터랙티브 데이터 시각화

축 범위 고정하기

고정 범위가 있는 bscols 애니메이션

bscols(filter_slider(id = "co2", label = "CO2 concentrations", 
                     sharedData = shared_data, column = ~co2),
        p1 %>% layout(xaxis = list(range = c(2.5, 5)), 
                      yaxis = list(range = c(-1.4, 1.55)))
)
R로 배우는 plotly 중급 인터랙티브 데이터 시각화

모든 요소 결합하기

bscols(widths = c(2, 5, 5),
  list(
    filter_checkbox(
      id = "four_regions", label = "Region", 
      sharedData = shared_data, group = ~four_regions
    ),
    filter_slider(
      id = "co2", label = "CO2 concentrations", 
      sharedData = shared_data, column = ~co2
    )
  ),
  p1,
  p2
)
R로 배우는 plotly 중급 인터랙티브 데이터 시각화

모든 요소 결합하기

최종 bscols 결과(정적)

R로 배우는 plotly 중급 인터랙티브 데이터 시각화

연습해 봅시다!

R로 배우는 plotly 중급 인터랙티브 데이터 시각화

Preparing Video For Download...