शुरू करेंमुफ़्त में शुरू करें

अंतर का विज़ुअलाइज़ेशन: Batman और Star Wars

पिछले अभ्यास में, आपने colors_joined बनाया था. अब आप एक बार प्लॉट बनाएँगे जिसमें हर रंग (name) के लिए एक बार होगा, और उसमें अंशों (fractions) का अंतर दिखेगा.

क्योंकि factors और visualization इस कोर्स के दायरे से बाहर हैं, हमने आपके लिए कुछ प्रोसेसिंग कर दी है: यह वह कोड है जिसने colors_joined टेबल बनाई, जो वीडियो में उपयोग होगी.

colors_joined <- batman_colors %>%
  full_join(star_wars_colors, by = "color_id", suffix = c("_batman", "_star_wars")) %>%
  replace_na(list(total_batman = 0, total_star_wars = 0)) %>%
  inner_join(colors, by = c("color_id" = "id")) %>%
  mutate(difference = fraction_batman - fraction_star_wars,
         total = total_batman + total_star_wars) %>%
  filter(total >= 200) %>%
  mutate(name = fct_reorder(name, difference)) 

यह अभ्यास पाठ्यक्रम का हिस्सा है

dplyr के साथ डेटा जॉइन करना

पाठ्यक्रम देखें

अभ्यास निर्देश

  • colors_joined टेबल का उपयोग करके एक बार प्लॉट बनाएँ जो Batman और Star Wars थीम्स में सबसे प्रमुख रंगों को दिखाए, और बार्स को उनके name के अनुसार रंगें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Create a bar plot using colors_joined and the name and difference columns
ggplot(___, aes(___, ___, fill = ___)) +
  geom_col() +
  coord_flip() +
  scale_fill_manual(values = color_palette, guide = "none") +
  labs(y = "Difference: Batman - Star Wars")
कोड संपादित करें और चलाएँ