เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Summarize across multiple variables

The across() function also works smoothly with summarize() for calculating across multiple rows. This is much faster and with less code than summarizing across each column individually.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Programming with dplyr

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Keep only rows corresponding to Bolivia.
  • Go across all columns containing "perc".
  • Find the minimum value for each of these columns.
  • Add "min_" to the beginning of each of the column names.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

imf_data %>% 
  # Focus on Bolivia rows
  filter(___) %>% 
  summarize(
    # Compute for all column names including "perc"
    across(___, 
           # Calculate the minimum value
           ___,
           # Prepend "min_" to column names
           ___)
  )
แก้ไขและรันโค้ด