Validating totals
In this lesson, you'll continue to work with the accounts
data frame, but this time, you have a bit more information about each account. There are three different funds that account holders can store their money in. In this exercise, you'll validate whether the total
amount in each account is equal to the sum of the amount in fund_A
, fund_B
, and fund_C
. If there are any accounts that don't match up, you can look into them further to see what went wrong in the bookkeeping that led to inconsistencies.
dplyr
is loaded and accounts
is available.
This exercise is part of the course
Cleaning Data in R
Exercise instructions
- Create a new column called
theoretical_total
that contains the sum of the amounts in each fund. - Find the accounts where the
total
doesn't match thetheoretical_total
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Find invalid totals
accounts %>%
# theoretical_total: sum of the three funds
___ %>%
# Find accounts where total doesn't match theoretical_total
___