I apologize for the low-level question, I am just starting out in programming.
I have the following tibble (which I know is not tidy) and I would like to compute the mean of the systolic pressure for each subject, using dplyr::group_by and dplyr::summarise():
bp_systolic2 <- tribble(
~ subject_id, ~ time, ~ systolic,
1, 1, 120,
1, 2, 118,
1, 3, 121,
2, 1, 125,
2, 2, 131,
3, 1, 141
)
I have tried this:
group_by(bp_systolic2, subject_id) %>%
summarise(mean_systolic = mean(systolic))
However, this just returns a 1x1 tibble with the mean of the whole systolic column. How can I return a tibble (presumably 3x1) which contains the mean systolic for each subject?