開始使用免費開始

驗證年齡

既然你已經在 total 金額裡發現一些不一致,你也懷疑 acct_age 欄位可能有不一致,並想檢查這些不一致是否彼此相關。請運用你在影片練習中學到的技巧,驗證每個帳戶的年齡,並查看那些 acct_age 不一致的列,是否正好也是 total 不一致的那些列。

已載入 dplyrlubridate,且 accounts 可供使用。

本練習屬於課程

R 的資料清理

檢視課程

練習說明

  • 建立一個名為 theoretical_age 的新欄位,根據 date_opened 計算每個帳戶的年齡。
  • 找出 acct_agetheoretical_age 不相符的帳戶。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Find invalid acct_age
accounts %>%
  # theoretical_age: age of acct based on date_opened
  mutate(theoretical_age = ___) %>%
  # Filter for rows where acct_age is different from theoretical_age
  ___
編輯並執行程式碼