【发布时间】:2021-08-21 07:17:41
【问题描述】:
我创建了以下数据框:
condition <- rep(c("Pretreatment", "Normal"), 4)
value <- c( "3.6", "0.2", "5.6", "0.2", "7.4", "0.2", "8.8", "0.2")
time<- c("5","5", "10", "10", "15","15", "20", "20")
domedata <- data.frame(time, condition, value)
我想按顺序保持 x 中的时间条,因为它告诉我们时间 5 分钟、10 分钟、15 分钟、20 分钟。 ggplot 在最后绘制我的 5 分钟。我正在这样做:
ggplot(domedata, aes(fct_infreq(time), fill=condition, x=time, y=value)) +
geom_bar(position="dodge", stat = "identity")
【问题讨论】:
-
将时间转换为数字或尝试使用
forcats::fct_inorder。
标签: r dataframe ggplot2 bar-chart geom-bar