I'm trying to summarize a numeric response variable (above ground biomass [AGB]) by several categorical factors as well as date as a part of a larger project. The date is being read as a character and is being organized as 4/10/2020, 4/8/2020, 4/9/2020. Additionally, there is a column, Shoot.Plot, that is numbered 1-11 being ordered: 1, 10, 11, 2... and so on since it's being read as a character string (which is fine for the most part asides from the strange order). I've releveled the factors to what I want, but when I summarize the data using either get_summary_stats()
from the rstatix()
package or using summarize()
, the levels organization is lost.
Here's what I've tried:
df %>%
mutate(Date.Coll, factor(Date.Coll, levels = c("4/8/2020","4/9/2020","4/10/2020")),
Shoot.Plot, factor(Shoot.Plot, levels =
c("1","2","3","4","5","6","7","8","9","10","11"))) %>%
group_by(Date.Coll, Site, Eelgrass, Oyster, Shoot.Plot) %>%
filter(is.na(BGB),
Date.Coll=="4/8/2020" | Date.Coll=="4/9/2020" | Date.Coll=="4/10/2020") %>%
select(AGB) %>%
get_summary_stats(type="mean_se")
When I check the data frame right before the get_summary_stats()
line, the data is organized as I specified in the mutate function. Only after summarizing do both those go out the window.
Any suggestions? Thank you!