驗證年齡
既然你已經在 total 金額裡發現一些不一致,你也懷疑 acct_age 欄位可能有不一致,並想檢查這些不一致是否彼此相關。請運用你在影片練習中學到的技巧,驗證每個帳戶的年齡,並查看那些 acct_age 不一致的列,是否正好也是 total 不一致的那些列。
已載入 dplyr 與 lubridate,且 accounts 可供使用。
本練習屬於課程
R 的資料清理
練習說明
- 建立一個名為
theoretical_age的新欄位,根據date_opened計算每個帳戶的年齡。 - 找出
acct_age與theoretical_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
___