可视化 Pokemon
让我们来可视化 pokemon 数据。pokemon 数据集中包含很多变量,因此我们只选择几个确实希望作为 cognostics 使用的变量。
本练习是课程的一部分
使用 R 中的 Trelliscope 可视化大数据
练习说明
- 使用 dplyr 的
select()将数据集的变量缩减为pokemon、type_1、attack、generation_id和url_image。 - 使用
cog()函数,重新指定变量pokemon,使 Pokemon 的名称默认作为显示中的标签。 - 指定一个新变量
panel,让 trelliscope 指向url_image变量以进行面板绘图。 - 使用
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, ___)