我有一个这样的data.frame:
library(ggplot2)
library(reshape2)
tasks <- c("Review literature", "Mung data")
dfr <- data.frame(
name = factor(tasks, levels = tasks),
start.date = c("24/08/2010 01:00:01", "24/08/2010 01:00:10", "01/11/2010 01:30:00", "01/11/2010 02:00:00"),
end.date = c("24/08/2010 02:00:00", "24/08/2010 03:00:00", "01/11/2010 02:00:00", "01/11/2010 04:00:00")
)
mdfr <- melt(dfr, measure.vars = c("start.date", "end.date"))
我想使用 ggplot2 绘制这些数据,以便不同的日期在不同的方面,并且只有时间部分显示在 x 轴上?我试过类似的东西:
ggplot(mdfr, aes(as.Date(value, "%H/%M/%S"), name)) +
geom_line(size = 6) +
xlab("") + ylab("") +
theme_bw() + facet_wrap(~as.Date(value, "%d/%m/%Y"))
Error in layout_base(data, vars, drop = drop) :
At least one layer must contain all variables used for facetting