shosaco / vistime

Pretty timelines in R.
https://shosaco.github.io/vistime
GNU General Public License v3.0
170 stars 11 forks source link

Start and end days #33

Closed gadepallivs closed 11 months ago

gadepallivs commented 1 year ago

my data does not have a time or date values for start and end. I have just numerical numbers for days, example below. This throws error, is not of class 'POSIXct' class is numeric. is there any way to approach this kind of data?

data <- read.csv(text="group,event,start,end
                       Patient-1, diagnosis_window,0,15
                       Patient-1, treatment_windows,10,20
                       Patient-2, diagnosis_window,3,15
                       Patient-2, treatment_windows,5,20",
                 stringsAsFactors=FALSE)
shosaco commented 1 year ago

Hi @gadepallivs ,

you could add your days to an arbitrary date to make date values:

``` r
library(vistime)
#> Warning: Paket 'vistime' wurde unter R Version 4.2.3 erstellt
data <- read.csv(text="group,event,start,end
                       Patient-1, diagnosis_window,0,15
                       Patient-1, treatment_windows,10,20
                       Patient-2, diagnosis_window,3,15
                       Patient-2, treatment_windows,5,20",
                 stringsAsFactors=FALSE)

data$start <- data$start + Sys.Date()
data$end <- data$end + Sys.Date()
gg_vistime(data) + ggplot2::scale_x_datetime(labels = NULL, breaks = NULL)

I also removed the x axis labels afterwards in this example.

Best regards sandro