Hi all, apologies if this seems like a simple question. I am extremely new to R.
I am trying to compute summary statistics by group, so that I can do a Kruskal Wallis test. The data is essentially academic years as the groups and course fee amounts. I want to get a descriptive summary for the course fee amounts within each academic year.
I use the following code:
>group_by(dataframe, dataframe$ï..Course.start.academic.year) %>%
summarise(count = n(),
mean = mean(dataframe$Fee.amount, na.rm = TRUE),
sd = sd(dataframe$Fee.amount, na.rm = TRUE),
median = median(dataframe$Fee.amount, na.rm = TRUE),
IQR = IQR(dataframe$Fee.amount, na.rm = TRUE))
and get the following output:
# A tibble: 6 x 6
`dataframe$ï..Course.start.academic.year` count mean sd median IQR
<fct> <int> <dbl> <dbl> <dbl> <dbl>
1 2016-17 1930 13909. 8799. 11460 11547
2 2017-18 3486 13909. 8799. 11460 11547
3 2018-19 3123 13909. 8799. 11460 11547
4 2019-20 2767 13909. 8799. 11460 11547
5 2020-21 1989 13909. 8799. 11460 11547
6 2021-22 1014 13909. 8799. 11460 11547
Obviously it is getting the grouping and the count correct, but it is not giving me the individual descriptive statistics, just the ones for the dataset as a whole!
I already have tidyverse, ggpubr, dplyr and rstatix packages installed.
What am I doing wrong?
Many thanks