Using R dygraphs for fractional time points?

Is there a hack that exists for the use of the package dygraphsin R Shinya fractional time points? I understand that this pacakge is mainly for given time series, but I think it would be very useful as a survival graph.

For example, let's say I have the following data:

samp.data <- data.frame(Months=seq(0,10,by=0.5), Surv=seq(1,0,length.out=21))

head(samp.data)

  Months Surv
1    0.0 1.00
2    0.5 0.95
3    1.0 0.90
4    1.5 0.85
5    2.0 0.80
6    2.5 0.75

I know I can do the following:

samp.xts <- xts(samp.data[,-1], order.by=as.Date(samp.data[,1]))
dygraph(samp.xts) 

But this eliminates some information, and the x axis is the date instead of the value. I studied the javascript library "dygraphs" and there seems to be some functionality for non-time series data as well, but I haven't found anything related to the package yet R. Is there any code javascriptI can call from a function?

Thanks for any help.

+4
2

, , - , , . javascript valueFormatter axisLabelFormatter.

samp.data <- data.frame(Months=seq(0,10,by=0.5), Surv=seq(1,0,length.out=21))
samp.xts <- xts(samp.data[,-1], order.by=as.POSIXct(10*samp.data[,1],origin=as.Date("1970-01-01")))

:

dygraph( samp.xts ) %>%
  dyAxis(name="x",
         valueFormatter="function(d){ var date = new Date(d); return (date.getSeconds()/10) }",
         axisLabelFormatter="function(d){ return (d.getSeconds()/10) }"
  )

, , , , . , valueFormatter , axisLabelFormatter .

0

, " " . dygraphs , POSIXct, .

Date, .

?

samp.xts <- xts(samp.data[,-1], order.by=as.POSIXct(samp.data[,1]))
dygraph(samp.xts) 

as.POSIXct.

0
source

All Articles