開始使用免費開始

驗證總額

在本課中,你會繼續使用 accounts 資料框,但這次你掌握了每個帳戶的更多資訊。帳戶持有人可以把資金存入 3 種不同的基金。在這個練習中,你要驗證每個帳戶的 total 是否等於 fund_Afund_Bfund_C 金額的總和。若有任何帳戶對不上,你就可以進一步檢視,找出記帳流程中導致不一致的問題。

已載入 dplyr,且可使用 accounts

本練習屬於課程

R 的資料清理

檢視課程

練習說明

  • 建立一個名為 theoretical_total 的新欄位,內容為各基金金額的總和。
  • 找出 totaltheoretical_total 不相符的帳戶。

動手互動練習

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

# Find invalid totals
accounts %>%
  # theoretical_total: sum of the three funds
  ___ %>%
  # Find accounts where total doesn't match theoretical_total
  ___
編輯並執行程式碼