I am having issues on how to proceed with this R query. I have to create an independent tidy data set with the average of each variable for each activity and each subject.
The data set data_table looks like this:
These data have 10299 obs. (rows) and 81 variables (columns). Also, there are 30 subjects (1,...,30) and 6 different activities (STANDING, WALKING, WALKING UPSTAIRS, WALKING DOWNSTAIRS, SITTING, LAYING).
Therefore, I understand I need to have a mean for each variable corresponding to each one of the combinations of subject and activity. Example:
Col1 Col2 Col 3 Col4
subject activity timeBody...-X mean timeBody...-Y mean
1 STANDING corresponding mean corresponding mean
... ... ... ...
30 LAYING corresponding mean corresponding mean
I tried many things with the group_by, lapply, sumarrise,...but I have not been able to figure this out. Can you help me with this?