0

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

A. Suliman
  • 12,923
  • 5
  • 24
  • 37
Cindy CM
  • 1
  • 1
  • 5
    Please read [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Share just enough data to be representative for your problem, the code that you have tried and expected output. This will make much easier for others to help you. – markus Dec 16 '18 at 08:57
  • 2
    `arrange` works as expected here see `?arrange`. I think you need `dplyr::group_by`. – A. Suliman Dec 16 '18 at 09:11
  • Add data using `dput(df)` not links to Google docs. – NelsonGon Dec 17 '18 at 02:18

0 Answers0