not sure what I'm doing wrong, I have the following dataset:
install.packages("random")
library("random")
df <- data.frame(V1 = randomNumbers(n = 18,min = 1,max = 20, col=1),
factor_col = c(rep("A", 18)),
mouse_ID = c(1:18))
df2 <- data.frame(V1 = randomNumbers(n = 14,min = 1,max = 20, col=1),
factor_col = c(rep("B", 14)),
mouse_ID = c(1:14))
df3 <- data.frame(V1 = randomNumbers(n = 13,min = 1,max = 20, col=1),
factor_col = c(rep("C", 13)),
mouse_ID = c(6:18))
Table = bind_rows(df, df2)
Table = bind_rows(Table, df3)
Table$mouse_ID = as.factor(Table$mouse_ID)
Table$factor_col = as.factor(Table$factor_col)
Now I want to have a mean value of V1 for each mouse ID so I do:
Table2 = Table %>%
group_by(mouse_ID) %>%
summarise(mean_V1 = mean(V1, na.rm = TRUE))
but it only spits out one mean value of V1, not by mouse ID or anything. Is this because each variable of mouse ID doesn't re-cur exactly with the same frequency?
Thank you!