在r中显示起始日期和截止日期范围的数据的图表
我有以下投资购买和到期的数据在r中显示起始日期和截止日期范围的数据的图表,r,graph,date-range,R,Graph,Date Range,我有以下投资购买和到期的数据 investment <- as.character(c("First", "Second", "Third")) from <- as.Date(c("2019-11-01", "2020-02-25", "2020-06-10")) to <- as.Date(c("2020-08-31","20
investment <- as.character(c("First", "Second", "Third"))
from <- as.Date(c("2019-11-01", "2020-02-25", "2020-06-10"))
to <- as.Date(c("2020-08-31","2021-02-24", "2020-08-09"))
amount <- as.numeric(c(20000,15000,17000))
df <- data.frame(investment, from, to, amount)
investment您可以使用geom\u linerange()
从ggplot2
library(ggplot2)
ggplot(df) +
geom_linerange(aes(y = investment, xmin = from, xmax = to ), size = 18,
color = "orange") +
xlab("date")
非常感谢。这正是我想要的