포켓몬 시각화
pokemon 데이터를 시각화해 볼까요? pokemon 데이터셋에는 변수가 많으니, 코그노스틱으로 정말 사용하고 싶은 몇 가지만 골라 보겠습니다.
이 연습은 강의의 일부입니다
R에서 Trelliscope로 빅데이터 시각화하기
연습 안내
- dplyr의
select()를 사용해 데이터셋의 변수를pokemon,type_1,attack,generation_id,url_image로만 줄이세요. cog()함수를 사용해pokemon변수를 다시 지정하여, 디스플레이에서 포켓몬 이름이 기본 레이블로 보이도록 하세요.- 패널 플로팅을 위해 trelliscope가
url_image변수를 참조하도록 하는 새 변수panel을 지정하세요. trelliscope()로 디스플레이를 만들고 이름을"pokemon"으로 지정하며, 기본으로 3행 6열이 되도록 설정하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
library(dplyr)
library(trelliscopejs)
# Create a new data frame to use for plotting
pokemon2 <- pokemon %>%
# Reduce the variables in the dataset
select(pokemon, type_1, attack, generation_id, url_image) %>%
mutate(
# Respecify pokemon
pokemon = cog(val = ___, default_label = ___),
# Create panel variable
panel = img_panel(___)
)
# Create the display
trelliscope(pokemon2, ___)