在R中创建时间线

kpa*_*ars 3 timeline r ggplot2

因此,我的目的是显示并发卫生技术的时间轴,其持续时间为矩形或平铺几何图形,其宽度代表在x轴上指定时间间隔内的持续时间,并由制造商沿着Y轴显示。

我有2001年1月1日至2016年3月31日期间来自4个不同制造商的16个案例

我正在使用ggplot2timeline软件包。下面的例子在网上找到的,我修改了数据,只列标题:DeviceManufacturerStartDateEndDate,以及确保有没有空的情况。因此,我为迄今为止仍被许可的许多技术添加了人为的终止日期。

再次尝试使用样本数据,我们有:

    device.data <- data.frame(
    DeviceName = c("Cypher Sirolimus DES", "Taxus Express 2", "Cypher Select Sirolimus DES",
              "Cypher Select Plus Sirolimus DES", "Taxus Liberte", "Endeavor ABT578",
              "Endeavor Sprint Zotarolimus DES", "Xience V", "Taxus Element Monrail ION",
              "Xience Nano", "Promus Element Plus", "Xience Prime",
             "Endeavor Resolute DES","Endeavor Resolute Integrity DES", "Promus Premier", "Xience Xpedition LL and SV"),
    DeviceManufacturer = c("Cordis Cashel","Boston Scientific","Cordis Cashel",
                     "Cordis Cashel","Boston Scientific","Medtronic Inc",
                     "Medtronic Inc", "Abbott Vascular", "Boston Scientific",
                     "Abbott Vascular","Boston Scientific", "Abbott Vascular",
                     "Medtronic Inc", "Medtronic Inc","Boston Scientific", "Abbott Vascular"),
    start_date = as.Date(c("2002-11-15", "2003-09-09", "2005-10-21", 
                     "2006-10-25","2008-02-05", "2008-02-27",
                     "2009-06-10", "2009-08-21", "2011-08-19",
                     "2011-10-24", "2012-01-30", "2012-04-10",
                     "2012-04-14", "2013-03-07", "2013-09-30", "2014-02-19")),
    end_date = as.Date(c("2007-07-18", "2010-11-10", "2007-07-18",
                   "2013-04-05", "2013-11-01", "2016-03-31",
                   "2016-03-31", "2016-03-31", "2011-09-16",
                   "2016-03-31", "2016-03-31", "2016-03-31",
                   "2016-03-31", "2016-03-31", "2016-03-31", "2016-03-31")),
    stringsAsFactors = FALSE
    )
    #data visualization
    timeline(device.data)
Run Code Online (Sandbox Code Playgroud)

但是,在绘制数据时,所有几何图形都叠加在一个组中。我需要帮助以使文本适合几何图形。

sho*_*aco 5

使用vistime软件包和您提供的软件包device.data

library(vistime)
vistime(device.data, events = "DeviceName", groups = "DeviceManufacturer", 
                     start = "start_date", end = "end_date")
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明