ポケモンを可視化する
ポケモンのデータを可視化してみましょう。pokemon データセットには変数が多いため、コグノスティックとして使いたいものだけに絞り込みます。
この演習はコースの一部です
RのTrelliscopeでビッグデータを可視化する
演習の手順
- dplyrの
select()を使って、データセットの変数をpokemon、type_1、attack、generation_id、url_imageのみに絞り込みましょう。 cog()関数を使って変数pokemonを再指定し、ポケモンの名前がデフォルトでディスプレイのラベルとして表示されるようにしましょう。- 新しい変数
panelを指定して、パネルの描画にurl_image変数を使用するよう trelliscope に指示しましょう。 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, ___)