gpt4 book ai didi

r - 如何在R中创建模式表

转载 作者:行者123 更新时间:2023-12-04 10:55:45 25 4
gpt4 key购买 nike

我想在 R 中制作一张如下所示的表格。我不确定该表格的名称以及可以在 R 中执行此操作的包。

# 我想在 R 中创建下表

table graphic

下面是我的数据集的样子:

dat1 <- data.frame(ani=c("cat","dog","frog","fish","rat","snake","chicken"),
year=c(2015,2016,2015,2018,2019,2017,2018),
start_date=c("01-Jan-2015", "30-Mar-2016","08-Aug-2015",
"25-Nov-2018","05-Apr-2019","03-Mar-2017",
"11-Oct-2018"),
end_date=c("02-Jan-2016","30-Jun-2016","07-Nov-2015","24-Mar-2019",
"04-Jul-2019","02-Jun-2017","10-Dec-2018"))

最佳答案

这是您可能想要玩的东西:

library(ggplot2)

# May need to Sys.setlocale("LC_TIME", "C")
dat1$start_date <- as.Date(dat1$start_date, "%d-%b-%Y")
dat1$end_date <- as.Date(dat1$end_date, "%d-%b-%Y")

ggplot(dat1) +
geom_segment(aes(x = ani, xend = ani, y= start_date, yend = end_date), size = 10) +
coord_flip()

enter image description here

关于r - 如何在R中创建模式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59215162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com