ggvis icon indicating copy to clipboard operation
ggvis copied to clipboard

Error in Math.Date(x) : abs not defined for "Date" objects

Open puritanne opened this issue 9 years ago • 4 comments

In ggvis v0.4.1.9000 I have an error trying to plot a dataframe with Date object on 'x' axis.

Here is a simple example to reproduce:

library (ggvis)

df <- data.frame(
  date = seq(as.Date("2015-01-01"), as.Date("2015-01-30"), by=1),
  sessions = 1:30
)

df %>%
  ggvis (~date, ~sessions) %>%
  layer_bars()

This code generates an error:

Error in Math.Date(x) : abs not defined for "Date" objects

If I convert date object to character everything works fine.

puritanne avatar Apr 26 '15 11:04 puritanne

Same issue experienced here:

http://stackoverflow.com/questions/31062750/ggvis-barchart-using-dates-as-x-axis

voxnonecho avatar Jun 26 '15 03:06 voxnonecho

I fixed this by including the following in my code:
abs.Date <- function(x){x}

ScottPayseur avatar Feb 25 '16 16:02 ScottPayseur

@ScottPayseur Would you mind expanding a bit on that previous comment please ?

voxnonecho avatar Mar 16 '16 23:03 voxnonecho

@voxnonecho What @ScottPayseur means is that you can fix the error by manually defining the absolute value for date objects. Converting the date object to character is not needed (makes labeling your axis easier as well). Just copy and add this exact code at the start of your code:

abs.Date <- function(x){x}

BasWagenmaker avatar Sep 22 '16 10:09 BasWagenmaker