r - rcharts: nPlot Formating x-axis with dates -
i have data.frame dates , integers:
df <- data.frame(date=seq.date(from=as.date("2012/01/01"), to=as.date("2012/02/28"), by="1 day"), y=1:59) i want plot data.frame rcharts nplot:
n <- nplot(y ~ date, grouping = "team", info = df, type = "linechart") n$xaxis( tickformat = "#! function(d) {return d3.time.format('%y-%m-%d')(new date(d));} !#", rotatelabels = -90 ) n but x-axis isn't formatted correctly.
so how format dates correctly?
in r as.numeric(somedate) days since origin. here need milliseconds origin. should be
df <- data.frame(date=seq.date(from=as.date("2012/01/01", origin="1970-01-01"), to=as.date("2012/02/28", origin="1970-01-01"), by="1 day"), y=1:59) n <- nplot(y ~ date, grouping = "team", info = df, type = "linechart") n$xaxis( tickformat = "#! function(d) {return d3.time.format('%y-%m-%d')(new date(d*1000*3600*24));} !#", rotatelabels = -90 ) n r rcharts
No comments:
Post a Comment