Entering edit mode
5.3 years ago
bgraphit
▴
20
Hi I need some advise as to how to go from TEST_play data frame to a data frame that includes individual name, and the average of the counts.1 counts.2 for that Peak.
Example:
>head(TEST_play)
name counts.1 counts.2
1 Peak160 97 487
2 Peak160 425 371
3 Peak328 0 104
4 Peak328 13 20
5 Peak344 2 39
6 Peak344 7 63
Desired output
>head(average_TEST_play)
name counts.1 counts.2
1 Peak160 261 429
2 Peak328 6.5 62
etc,,,,
,
> sapply(TEST_play, class)
name counts.1 counts.2
"factor" "numeric" "numeric"
What have you tried? Look at dplyr's
group_by()
andsummarise()
functions. There are ways to do it in base R too, but this might be easier.