thomasp85/gganimate

Error: Invalid input type, expected 'double' actual 'logical' when using transition_time with a POSIXct variable

JojoOno opened this issue · 2 comments

I have a simple features object with 2 grouping variables (tag and hour)

> anim_data
Simple feature collection with 82 features and 2 fields
geometry type:  MULTIPOINT
dimension:      XY
bbox:           xmin: 478487.4 ymin: 6499861 xmax: 490542.8 ymax: 6504338
projected CRS:  WGS 84 / UTM zone 30N
# A tibble: 82 x 3
# Groups:   tag [1]
   tag   hour                                                geometry
   <chr> <dttm>                                      <MULTIPOINT [m]>
 1 64308 2018-04-19 17:25:00                     ((480036.3 6500805))
 2 64308 2018-04-19 18:30:00                     ((480088.3 6500819))
 3 64308 2018-04-19 18:35:00   ((480072.8 6500858), (480087 6500931))
 4 64308 2018-04-19 18:40:00                     ((480092.6 6500959))
 5 64308 2018-04-19 18:45:00 ((480086.1 6500998), (480085.5 6500948))
 6 64308 2018-04-19 18:50:00                     ((480137.4 6501052))
 7 64308 2018-04-19 18:55:00                     ((480194.6 6501139))
 8 64308 2018-04-19 19:05:00                     ((480136.9 6501163))
 9 64308 2018-04-19 19:10:00                     ((480073.9 6501161))
10 64308 2018-04-19 19:15:00                     ((480067.6 6501240))

The hour variable is a POSIXct object

> class(anim_data$hour)
[1] "POSIXct" "POSIXt" 

When trying to plot the animation using $hour as the transition time I get the error:

> animated_plot <- ggplot() +
+   annotation_spatial(my_map, fill = "grey", lwd = 0) +
+   layer_spatial(anim_data, aes(color = tag)) +
+   scale_color_viridis_d() + 
+   theme(legend.position = "none") +
+   gganimate::transition_time(hour) +
+   shadow_wake(wake_length = 0.1)
> 
> gganimate::animate(animated_plot)
Error: Invalid input type, expected 'double' actual 'logical'

I have tried making hour an integer variable and also tried using transition_states() with hour as a factor and I still get the same error.

Am I missing something obvious here?

Hi,

I was receiving a similar error while trying to render an animated map and, since I could not find any other post other than your question on this error, I recently posed a similar question on the stackoverflow. The advise I received was to update the R Studio, which I did so (my current version is 4.2.1) Now, I am not receiving such an error anymore. Therefore, if this is not too late :), updating R Studio might solve your problem.

My guess is that this has been fixed in the dev versions of tweenr, transformr, and gganimate, but given that I can't reproduce your code due to lack of reprex I can't know for sure. If the issue persist feel free to reopen