I'm currently working with csv's with data about test participants on a diet program. One CSV has the the partcipants information 'suubject id', chosen group', 'extra calories' etc.
The second set of csv's are about the different diet groups, meals, calories etc. (of which there are 10)
My task was to find the total calories of each group then find the total calories of each participants chosen group.
To get the total calories of each group I just made a variable that summed the total calories of each group
one <- sum(groupOne$calories)
Then I cleaned the data up a bit in the participants file by removing the 'g' in the row name.
I would ideally like to get some output that has the participants subjectID and their the total calories of their group. Something like below:
|SubjectID||Group||Groups Total Calories|
1 G3 100cal
2 G6 200cal
After that I'm kind of stuck, I don't quite know how to group the two together to together and spit out some data that matches the participants to the groups to output a clean display of the participants subjectId, their group and the total calories of that group.