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

अंतर देखने के लिए सेट्स को एग्रीगेट करना

दो अलग-अलग सेट्स और उनमें शामिल LEGO पीस के प्रकारों की तुलना करने के लिए, हमें डेटा को अलग-अलग थीम में एग्रीगेट करना होगा। साथ ही, जैसा आपने वीडियो में देखा, हम एक कॉलम भी जोड़ना चाहेंगे ताकि हम हर सेट में मौजूद विशेष पीस के हिस्से (fractions) समझ सकें, सिर्फ पीस की कुल संख्या देखने के बजाय.

inventory_parts_themes टेबल आपके लिए पहले से लोड की गई है.

inventory_parts_themes <- inventories %>%
  inner_join(inventory_parts, by = c("id" = "inventory_id")) %>%
  arrange(desc(quantity)) %>%
  select(-id, -version) %>%
  inner_join(sets, by = "set_num") %>%
  inner_join(themes, by = c("theme_id" = "id"), suffix = c("_set", "_theme"))

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

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

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

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

  • "Batman" थीम के लिए फ़िल्टर जोड़कर batman_colors ऑब्जेक्ट बनाएँ.
  • batman_colors में fraction नाम का कॉलम जोड़ें जो total को total के sum से भाग देने पर मिले मान को दिखाए.
  • यही स्टेप्स दोहराकर "Star Wars" सेट डेटा को फ़िल्टर और एग्रीगेट करें और star_wars_colors ऑब्जेक्ट बनाएँ.
  • star_wars_colors में fraction कॉलम जोड़ें जो total का fraction दिखाए.

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

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

batman_colors <- inventory_parts_themes %>%
  # Filter the inventory_parts_themes table for the Batman theme
  filter(name_theme == ___) %>%
  group_by(color_id) %>%
  summarize(total = sum(quantity)) %>%
  # Add a fraction column of the total divided by the sum of the total 
  mutate(___)

# Filter and aggregate the Star Wars set data; add a fraction column
star_wars_colors <- inventory_parts_themes %>%
  ___
	

कोड संपादित करें और चलाएँ