【发布时间】:2020-06-09 11:50:41
【问题描述】:
我正在根据大数据(2150000 例)绘制两组体重的简单箱线图。 除了去年的最后一组之外,所有组的中位数都相同,但在箱线图上,它的绘制方式与其他组相同。
#boxplot
ggplot(dataset, aes(x=Year, y=SUM_MME_mg, fill=GenderPerson)) +
geom_boxplot(outlier.shape = NA)+
ylim(0,850)
#median by group
pivot <- dataset %>%
select(SUM_MME_mg,GenderPerson,Year )%>%
group_by(Year, GenderPerson) %>%
summarise(MedianValues = median(SUM_MME_mg,na.rm=TRUE))
我无法弄清楚我做错了什么,或者哪些数据在箱线图计算或中值函数中更准确。 R 不返回错误或警告。
#my data:
> dput(head(dataset[,c(1,7,10)]))
structure(list(GenderPerson = c(2L, 1L, 2L, 2L, 2L, 2L), Year = c("2015",
"2014", "2013", "2012", "2011", "2015"), SUM_MME_mg = c(416.16,
131.76, 790.56, 878.4, 878.4, 878.4)), row.names = c(NA, 6L), class = "data.frame")
【问题讨论】:
标签: r ggplot2 dplyr boxplot median