hello,

I've a number of timeseries into a database and want to display these timeseries into graph.
Now the code below works well, but as the user can select which 
timeseries should be shown (up to 20 timeseries) the code below should 
be dynamic and can be quiet large and complex.
Is there an easier way to convert a database result into timeseries 
accepted by dygraph ?
    SQL <- "select Date, M, G, N from Compare_Model"
    df <- dbGetQuery ( con, statement = SQL )

zon1 <- xts ( df$M, as.POSIXct ( df$Date, format="%Y-%m-%d %H:%M:%S") ) zon2 <- xts ( df$G, as.POSIXct ( df$Date, format="%Y-%m-%d %H:%M:%S") ) zon3 <- xts ( df$N, as.POSIXct ( df$Date, format="%Y-%m-%d %H:%M:%S") )
    zonnen <- Reduce ( function(...) merge(..., all=TRUE ), list ( zon, 
zon2, zon3 ))
    dygraph ( zonnen )


thanks,

Stef

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to