Hello! I will start by saying that I'm new to R so this may be a simple user error, but I'm having a scenario where the code below using Group_By and Summarise for simple descriptive statistics 'works' in the sense that no Console or other errors are thrown, but the output is wrong (i.e. the 'min' is not the min for that grouped variable).
I'm using a simplified data set that looks as follows (but with additional rows):
DAA1_Dataset.Tenure DAA1_Dataset.Monthly.Pay DAA1_Dataset.Gender..binary.
1 1 800 0
2 1 1100 0
3 1 1200 1
4 1 1300 1
5 2 1400 1
6 2 1500 1
However when I run the following code against it, I get an output table, but it consistently lists the same results for both 'groups' even though they are clearly different.
library("dplyr")
descriptives <- Compact_DAA1 %>%
dplyr::group_by(Compact_DAA1$DAA1_Dataset.Gender..binary.) %>%
dplyr::summarize(Mean = mean(Compact_DAA1$DAA1_Dataset.Monthly.Pay),
Min = min(Compact_DAA1$DAA1_Dataset.Monthly.Pay),
Max = max(Compact_DAA1$DAA1_Dataset.Monthly.Pay)
)
I know the 'dplyr::' shouldn't be required but I tried troubleshooting based on some other common errors.
As noted the output looks 'wrong' with the table as shown:
# A tibble: 2 × 4
`Compact_DAA1$DAA1_Dataset.Gender..binary.` Mean Min Max
<int> <chr> <chr> <chr>
1 0 1,850.00 800 2900
2 1 1,850.00 800 2900
Any idea why it's not computing the correct values?