Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does rCharts deals with dates #284

Closed
pachevalier opened this issue Oct 24, 2013 · 2 comments
Closed

How does rCharts deals with dates #284

pachevalier opened this issue Oct 24, 2013 · 2 comments

Comments

@pachevalier
Copy link

I'd like to draw a simple time series plot. I have a date variable and a numeric variable. But when I try to do the graph using rCharts, it doesn't recognize my date variable as a date. Here is my gist file https://gist.github.com/blaquans/7140811

Do you have any solution ?

@timelyportfolio
Copy link
Contributor

Very good question. We are working towards a more universal implementation of the R to JS date conversion as referenced by #43 , but as of now, each of the JS libraries handles dates differently. For Rickshaw as shown in your example, this will work.

require(rCharts)
fake  <- data.frame(date = seq(as.Date("1990-01-01"), as.Date("1991/01/01"), by = "day"))
fake$x  <- rnorm(nrow(fake))
str(fake)
fake$d  <- as.numeric(as.POSIXct(fake$date))
r <- Rickshaw$new()
r$layer(x ~ d, data = fake, type = "line")
r$show()

@ramnathv wrote a little function to ease the conversion for Rickshaw.

In general JS likes dates in as.numeric(as.POSIXct(myRdate)) * 1000. Hope this helps. Please let us know if it does not.

@pachevalier
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants