การแสดงภาพข้อมูล Pokemon
มาลองแสดงภาพข้อมูล Pokemon กัน ชุดข้อมูล pokemon มีตัวแปรจำนวนมาก ดังนั้นเราจะเลือกเฉพาะตัวแปรที่ต้องการใช้เป็น cognostics เท่านั้น
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การแสดงภาพข้อมูลขนาดใหญ่ด้วย Trelliscope ใน R
คำแนะนำการฝึกหัด
- ลดตัวแปรในชุดข้อมูลให้เหลือเฉพาะ
pokemon,type_1,attack,generation_idและurl_imageโดยใช้select()ของ dplyr - กำหนดตัวแปร
pokemonใหม่เพื่อให้ชื่อของ Pokemon แสดงเป็น label ใน display โดยค่าเริ่มต้น โดยใช้ฟังก์ชันcog() - กำหนดตัวแปรใหม่ชื่อ
panelเพื่อชี้ให้ trelliscope ใช้ตัวแปรurl_imageสำหรับการ plot panel - สร้าง display ด้วย
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, ___)