I have been doing most of my data cleaning in excel but I am moving to R. So, I am a new R user. I am trying to find the difference in the two bednights columns from the clients. I want to make sure that when I am subtracting, that I am subtracting from apples to apples and not apple to Banana. The code below is what I put in; however, the result is not what I was looking for.
ComparingeEnrollment %>%
arrange(`FullNameFruit1.1`, `Full name`) %>%
mutate(Difference = BednightsFruit1.1 - sum_Bednights)
When you look at the way the names of the clients are arranged.I can see that they are not both arranged. Only one is. Picture of result, For example, you will see apple, banana, pear, versus apple, banana, blue berry. This throws my calculations because I am not subtracting from the correct client. This is easy to do in excel and I believe it can be easy in R but I do not know how to do it.
Google tables link to access the data. https://docs.google.com/spreadsheets/d/189nj0a_SCvDFKmaDJUNjJRsOWizkuxhJfA1-a2s87r0/edit?usp=sharing