thomasp85 / tweenr

Interpolate your data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Off-by-one error in `tween_elements()` when colors are included

JoFrhwld opened this issue · comments

This can be illustrated with a slightly modified version of the dropping balls example:

d <- data.frame(x = rnorm(20), y = rnorm(20), time = sample(100, 20), alpha = 0,
                colour = "goldenrod",
                size = 1, ease = 'linear', id = 1:20,
                stringsAsFactors = FALSE)
d2 <- d
d2$time <- d$time + 10
d2$alpha <- 1
d2$size <- 3
d2$ease <- 'linear'
d3 <- d2
d3$time <- max(d2$time)
df <- bind_rows(d, d2, d3)

dt <- tween_elements(df, 'time', 'id', 'ease', nframes = 500)

This returns the error:
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 5432, 5431

The problem does not occur if the color column is omitted. I'm not sure where exactly the problem is in the code.