thomasp85 / tweenr Goto Github PK
View Code? Open in Web Editor NEWInterpolate your data
License: Other
Interpolate your data
License: Other
Prepare for release:
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
rhub::check(platform = 'ubuntu-rchk')
rhub::check_with_sanitizers()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_news_md()
usethis::use_dev_version()
See https://thomasp85.r-universe.dev/
Somewhat interesting, it seems that the current master (dev) version of tweenr was successfully built and deployed when it was committed, but has since then started failing, I think due to changes in cpp11 0.4. @jimhester
This is my first bug report and hope I'm doing this correctly. Feedback is welcomed, and most off thank you for your free software and contributions
# Reprex for tweenr
tribble(
~DATE, ~temp, ~humidity, ~wind_speed,
'2019-08-05 00:53:00', 75, 60, 6,
'2019-08-05 01:53:00', 73, 66, 5,
'2019-08-05 02:53:00', 71, 68, 8,
'2019-08-05 03:53:00', 71, 63, 10,
'2019-08-05 04:53:00', 70, 64, 9,
'2019-08-05 05:53:00', 69, 59, 9,
'2019-08-05 06:53:00', 71, 55, 9,
'2019-08-05 07:53:00', 73, 51, 5,
'2019-08-05 08:53:00', 77, 43, 5,
'2019-08-05 09:53:00', 77, 48, 7) %>%
mutate(DATE = ymd_hms(DATE)) -> in_dat
# create tibble with 15 minute increments
(add_mins <- tibble(DATE = seq(in_dat$DATE[1], in_dat$DATE[10], by = 900)))
add_mins %>% left_join(in_dat) # looks good
(add_mins %>% left_join(in_dat) %>%
tweenr::tween_fill(., ease = 'linear') -> test) # time now starts earlier
min(in_dat$DATE)
test %>% slice(17) # nearly the same time as first row (off by on sec, fine)
# but values for first row of in_dat are attributed to
min(test$DATE)
Could you please write the code of the a animations on the main github tweenr page or the help files, please?
With an example with gganimate, please.
Purpose is to take a df along with group id and time and for each group create equidistant rows based on the given times... Kind of like approx but for data frames
tween_at(from, to, at, ease)
will allow you to get interpolation at a specific point. vectorised along from, to, and at with recycling
It is a bit error prone right now to make a simple tween between two states where the start and end should be included
Hi
I am trying to create an animation of my first bicycle ride of 2017. I have a data frame with latitude longitude gradient and n (indicating the order of points).
I used tween_appear()
to interpolate between the points but it is not clear to me how to use .age
and .frame
to create an animation with gganimate()
.
Here is some sample code, I have dputted the data into a gist to save space in this issue.
The map in the code creates the animation for lat_lon
as I could not work out how to do it with the tween_data
.
# data
lat_lon <- data_from_link
# make up new data using tweenr
tween_data <- tween_appear(lat_lon, 'n', nframes = 200)
# make a bbox
bbox <- ggmap::make_bbox(lat_lon$lon, lat_lon$lat, f = 0.3)
# get map
map <- suppressWarnings(suppressMessages(get_map(bbox, maptype = 'satellite')))
# plot of just the lat_lon data
le_plot <- ggmap(map) +
coord_fixed(ratio = 1) +
theme(axis.title = element_blank()) +
geom_path(aes(x = lon, y = lat, col = grad, frame = n, cumulative = T), data = lat_lon, size = 2) +
coord_cartesian() +
scale_color_distiller('Gradient (%)', palette = 'Spectral') +
facet_wrap(~ .frame)
animation::ani.options(interval = 1/24)
gg_animate(le_plot, 'first_ride_2017.gif', title_frame = F)
Any tips or help much appreciated.
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.
I tried installing tweenr with devtools
devtools::install_github("thomasp85/tweenr")
but I'm getting the following error:
g++-4.4 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
/bin/sh: g++-4.4: command not found
make: *** [RcppExports.o] Error 127
ERROR: compilation failed for package ‘tweenr’
I tried installing gcc version 4.4 with homebrew (I'm on a Mac), but it looks like the oldest version available is 4.9. Any thoughts on what might be going wrong? I'm going to try reinstalling Rcpp and see if that helps.
Thanks! Andrew
It seems we hit a regression when trying to use the tween_component
Error: cannot create std::vector larger than max_size()
In addition: Warning message:
In numeric_element_interpolator(as.numeric(data), as.integer(group), :
NAs introduced by coercion to integer range
This is most likely line 24 (ease_seq) in numeric_element_interpolator fn:
21 for (i = 1; i < data.size(); ++i) {
22 if (current_group == group[i]) {
23 int nframes = frame[i] - frame[i-1];
24 std::vector<double> ease_points = ease_seq(ease[i-1], nframes);
25 for (size_t j = 0; j < ease_points.size(); ++j) {
26 tweendata.push_back(data[i - 1] + ease_points[j] * (data[i] - data[i - 1]));
27 tweengroup.push_back(current_group);
28 tweenframe.push_back(j + frame[i-1]);
29 }
30 } else {
Do you have any hints why this could happen?
Thanks
rbind
has shown to be a major bottleneck in the new tween_state()
setup and a faster alternative is needed. Currently dplyr::bind_rows()
is an obvious choice were it not for the huge dependency. Apparently bind_rows()
are being moved to the smaller vctrs
package, but I'm unsure whether tweenr
should depend on dplyr
for an intermediary period
Steps to reproduce:
library(tweenr)
x <- readRDS(gzcon(url("https://www.dropbox.com/s/rc6l97av6dgzeyp/tweenr-bug.RDS?dl=1")))
tween_elements(x, "PODFrame", "AnimalID", "ease", nframes=500)
Error message:
> tween_elements(x, "PODFrame", "AnimalID", "ease", nframes=500)
Error: std::bad_alloc
> traceback()
7: stop(list(message = "std::bad_alloc", call = NULL, cppstack = NULL))
6: .Call("tweenr_numeric_element_interpolator", PACKAGE = "tweenr",
data, group, frame, ease)
5: numeric_element_interpolator(data, group, frame, ease)
4: interpolate_numeric_element(d, group, frame, ease)
3: FUN(X[[i]], ...)
2: lapply(seq_along(data), function(i) {
d <- data[[i]]
switch(colClasses[i], numeric = interpolate_numeric_element(d,
group, frame, ease), factor = interpolate_factor_element(d,
group, frame, ease), character = interpolate_character_element(d,
group, frame, ease), colour = interpolate_colour_element(d,
group, frame, ease), date = interpolate_date_element(d,
group, frame, ease), datetime = interpolate_datetime_element(d,
group, frame, ease), constant = interpolate_constant_element(d,
group, frame, ease))
})
1: tween_elements(x, "PODFrame", "AnimalID", "ease", nframes = 500)
I'm trying to interpolate x-y-data (named lire and koli in the data) with tweenr.
With this command:
parlpos2 <- tween_elements(parlpos.tmp, time = 'jahr', group = 'id', ease = 'ease', nframes = 100)
I am getting the error: error: vector
And when I use this command:
parlpos2 <- tween_appear(data = parlpos.tmp, time = "jahr", nframes = 45)
and insert the data.frame to ggplot with geom_path and use frame = .frame
I am getting a full path like this, instead of something growing:
ggplot:
p <-ggplot(parlpos2[parlpos2$.age+2014>0,], aes(x = lire, y = koli, group = rat, colour=rat, label=jahr, frame = .frame)) +
geom_path(aes(cumulative = F))
The static data looks like this:
This is my data.frame parlpos.tmp
:
parlpos <- read.xlsx("sr_nr14.xlsx", sheetName = "position")
parlpos$id = parlpos$jahr - 1980
parlpos$ease = 'linear'
parlpos.tmp <- parlpos
jahr rat koli lire id ease
1 1981 NR 36.37 1.08 1 linear
2 1982 NR 35.55 1.29 2 linear
3 1983 NR 34.68 1.64 3 linear
4 1984 NR 33.60 1.82 4 linear
5 1985 NR 32.32 2.15 5 linear
6 1986 NR 30.74 2.53 6 linear
7 1987 NR 28.98 2.96 7 linear
8 1988 NR 27.22 3.37 8 linear
9 1989 NR 25.63 3.72 9 linear
10 1990 NR 24.38 4.02 10 linear
11 1991 NR 23.48 4.10 11 linear
12 1992 NR 22.86 4.18 12 linear
13 1993 NR 22.39 3.98 13 linear
14 1994 NR 22.01 3.84 14 linear
15 1995 NR 21.66 3.66 15 linear
16 1996 NR 21.26 3.48 16 linear
17 1997 NR 20.87 3.35 17 linear
18 1998 NR 20.45 3.40 18 linear
19 1999 NR 20.03 3.45 19 linear
20 2000 NR 19.59 3.64 20 linear
21 2001 NR 19.21 3.93 21 linear
22 2002 NR 18.85 4.33 22 linear
23 2003 NR 18.51 4.75 23 linear
24 2004 NR 18.17 5.17 24 linear
25 2005 NR 17.75 5.63 25 linear
26 2006 NR 17.39 6.00 26 linear
27 2007 NR 17.00 6.29 27 linear
28 2008 NR 16.66 6.51 28 linear
29 2009 NR 16.36 6.67 29 linear
30 2010 NR 16.11 6.74 30 linear
31 2011 NR 15.94 6.73 31 linear
32 2012 NR 15.87 6.70 32 linear
33 2013 NR 15.86 6.54 33 linear
34 2014 NR 16.00 6.45 34 linear
35 1981 SR 35.04 11.95 1 linear
36 1982 SR 34.51 12.28 2 linear
37 1983 SR 33.96 13.00 3 linear
38 1984 SR 33.67 13.16 4 linear
39 1985 SR 33.44 13.70 5 linear
40 1986 SR 33.40 14.31 6 linear
41 1987 SR 33.48 15.00 7 linear
42 1988 SR 33.74 15.61 8 linear
43 1989 SR 34.03 16.04 9 linear
44 1990 SR 34.32 16.48 10 linear
45 1991 SR 34.55 16.71 11 linear
46 1992 SR 34.64 16.89 12 linear
47 1993 SR 34.58 17.05 13 linear
48 1994 SR 34.52 17.39 14 linear
49 1995 SR 34.36 17.78 15 linear
50 1996 SR 34.17 18.20 16 linear
51 1997 SR 33.94 18.67 17 linear
52 1998 SR 33.78 19.15 18 linear
53 1999 SR 33.75 19.47 19 linear
54 2000 SR 33.81 19.85 20 linear
55 2001 SR 33.97 20.15 21 linear
56 2002 SR 34.15 20.30 22 linear
57 2003 SR 34.28 20.34 23 linear
58 2004 SR 34.38 20.18 24 linear
59 2005 SR 34.30 20.01 25 linear
60 2006 SR 34.12 19.45 26 linear
61 2007 SR 33.74 18.67 27 linear
62 2008 SR 33.21 17.69 28 linear
63 2009 SR 32.49 16.58 29 linear
64 2010 SR 31.67 15.37 30 linear
65 2011 SR 30.77 14.01 31 linear
66 2012 SR 29.86 12.72 32 linear
67 2013 SR 29.02 11.42 33 linear
68 2014 SR 28.35 10.15 34 linear
> str(parlpos.tmp)
'data.frame': 68 obs. of 6 variables:
$ jahr: num 1981 1982 1983 1984 1985 ...
$ rat : Factor w/ 2 levels "NR","SR": 1 1 1 1 1 1 1 1 1 1 ...
$ koli: num 36.4 35.5 34.7 33.6 32.3 ...
$ lire: num 1.08 1.29 1.64 1.82 2.15 2.53 2.96 3.37 3.72 4.02 ...
$ id : num 1 2 3 4 5 6 7 8 9 10 ...
$ ease: chr "linear" "linear" "linear" "linear" ...
data in Excel: sr_nr14.xlsx
Any idea what is going on?
Using the dev/GitHub version of tweenr, running the code section for Dancing Balls in the README verbatim return this error:
Error in rgb(int_col[, 1], int_col[, 2], int_col[, 3], maxColorValue = 255) :
colour intensity -320, not in 0:255
I believe this occurs in the code block beginning on line 87 in R/tween_states.R
, when attempting to interpolate_colour_state
(line 96), which in turn calls farver::convert_colour
, which I think is where the error arises.
Minimal reproducible example.
data <- data.frame( x = c(1, 2, 2, 1, 2, 2), y = c(1, 2, 2, 2, 1, 1), time = c(1, 4, 10, 4, 8, 10), group = c(1, 1, 1, 2, 2, 2), ease = rep('cubic-in-out', 6), fct = 'foo' )
data <- tween_elements(data, 'time', 'group', 'ease', nframes = 100)
Error in sort.list(y) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?
Fixes thomasp85/gganimate#324
Prepare for release:
git pull
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
rhub::check(platform = 'ubuntu-rchk')
rhub::check_with_sanitizers()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
git push
Submit to CRAN:
usethis::use_version('major')
devtools::submit_cran()
Wait for CRAN...
git push
usethis::use_github_release()
usethis::use_dev_version()
git push
I'm attempting to install tweenr on a Redhat cluster server and I'm getting the below error. Can you please let me know if I'm doing something wrong? Thanks
* installing *source* package ‘tweenr’ ...
** package ‘tweenr’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -m64 -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I'/home/kn6838/R/x86_64-redhat-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c RcppExports.cpp -o RcppExports.o
gcc -m64 -I"/usr/include/R" -DNDEBUG -I'/home/kn6838/R/x86_64-redhat-linux-gnu-library/4.0/Rcpp/include' -I/usr/local/include -std=c11 -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -c easing.c -o easing.o
easing.c: In function ‘SineEaseIn’:
easing.c:139:24: error: ‘M_PI_2’ undeclared (first use in this function)
return sin((p - 1) * M_PI_2) + 1;
As done in transformr - if the df has a .frame
column just use the last frame and add the preceeding to the result
CRAN tweenr is 1.0.1; this package is 0.1.5.9999
This error occurs for me when trying to tween multiple map datasets similarly as in this tutorial: https://www.r-graph-gallery.com/a-smooth-transition-between-chloropleth-and-cartogram/
It's also been mentioned on StackOverflow. I'm not sure what's going on, but basically I fixed this by making sure the first column is filled only with numbers. If the first column has strings, the code interprets this as colors for whatever reason.
Hello.
Could you please add another example as your falling balls one but where the balls instead of falling to the bottom (y=0) stay above the last one if there is one in this x positon?
I mean, balls (of the same size) appear at a given height (y=constant) at random x positions and fall.
And they pile up.
That could be used to show how the histogram is created.
With the given data set and the code below, the resulting animation should end in the year 2015, not 1995 as it does.
Here is the code. A error in the code?
`#### Reproducible code - error with missing frames in gganmate using tweenr ####
sessionInfo()
install.packages("ggplot2")
install.packages("dplyr")
install.packages("tweenr")
install.packages("readxl")
install.packages("xlsx")
install.packages("gapminder")
install.packages("ggrepel")
devtools::install_github("dgrtwo/gganimate")
library("ggplot2")
library("tweenr")
library("gganimate")
library("dplyr")
library("readxl")
library("xlsx")
library("ggrepel")
getwd()
setwd("C:/Users/brockjue/Documents/JB B/Fujitsu Americas/Marketing Intelligence/R/Animations")
getwd()
options(scipen = 999)
IT.industry <- read_excel("~/JB B/Fujitsu Americas/Marketing Intelligence/R/Animations/Evolution-dataset-GitHub.xlsx",
sheet = "timeline3-R", na = "NA")
IT.industry$Company <- as.factor(IT.industry$Company)
IT.industry$Company <- ordered(IT.industry$Company)
IT.industry$Year <- as.integer(IT.industry$Year)
IT.industry.tweenr <- IT.industry %>% split(.$Year) %>% tweenr::tween_states(tweenlength = 0.1, statelength = 0, ease = "linear", nframes = 600)
IT.industry.tweenr$FTEs2 <- IT.industry.tweenr$FTEs/1000
IT.industry.tweenr$Company <- ordered(IT.industry.tweenr$Company)
evolution3 <- ggplot(IT.industry.tweenr,
aes(x = Year, y = Profitability2, size = Revenue3, color = Company, frame = Year, cumulative = FALSE)) +
geom_point(alpha = .1, stroke = 0) +
geom_text(label = IT.industry.tweenr$Company, size = 3, hjust = 1, vjust = 1) +
#geom_hline(yintercept = 0) +
ggtitle("Year: ") +
scale_size_continuous(range = c(1,20)) +
theme_minimal() +
theme(legend.position="none") +
scale_x_continuous(limits = c(1950, 2020), breaks = c(1950, 1960, 1970, 1980, 1990, 2000, 2010, 2020)) +
scale_y_continuous(labels = scales::percent, limits = c(-0.8,0.8)) +
xlab("Year") + ylab("Profitability (Net income / revenue")
evolution3
gganimate(evolution3, "Evolution3-GitHub.mp4", interval=0.1, title_frame = TRUE, ani.width=800, ani.height=400)
sessionInfo:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
I have a data.frame containing information on stops and arrival/departure times of an arbitrary train:
name id lon lat routeIdx datetime_ct
1 Hamburg-Altona 8002553 9.935174 53.55270 0 2016-06-13 06:20:00
2 Hamburg Dammtor 8002548 9.989568 53.56075 1 2016-06-13 06:28:00
3 Hamburg Hbf 8002549 10.006908 53.55273 2 2016-06-13 06:34:00
4 Berlin-Spandau 8010404 13.197530 52.53447 3 2016-06-13 08:10:00
5 Berlin Hbf (tief) 8098160 13.369548 52.52559 4 2016-06-13 08:27:00
6 Berlin Südkreuz 8011113 13.365314 52.47504 5 2016-06-13 08:34:00
7 Lutherstadt Wittenberg 8010222 12.662286 51.86781 6 2016-06-13 09:09:00
8 Bitterfeld 8010050 12.316848 51.62286 7 2016-06-13 09:26:00
9 Leipzig Hbf 8010205 12.383333 51.34655 8 2016-06-13 09:48:00
10 Erfurt Hbf 8010101 11.038501 50.97255 9 2016-06-13 10:34:00
11 Fulda 8000115 9.683980 50.55472 10 2016-06-13 11:57:00
12 Würzburg Hbf 8000260 9.935777 49.80179 11 2016-06-13 12:33:00
13 Nürnberg Hbf 8000284 11.082989 49.44561 12 2016-06-13 13:31:00
14 Ingolstadt Hbf 8000183 11.437335 48.74454 13 2016-06-13 14:05:00
15 München Hbf 8000261 11.558338 48.14023 14 2016-06-13 14:41:00
The column datetime_ct
is as.POSIXct()
:
> str(ice)
'data.frame': 15 obs. of 6 variables:
$ name : chr "Hamburg-Altona" "Hamburg Dammtor" "Hamburg Hbf" "Berlin-Spandau" ...
$ id : chr "8002553" "8002548" "8002549" "8010404" ...
$ lon : num 9.94 9.99 10.01 13.2 13.37 ...
$ lat : num 53.6 53.6 53.6 52.5 52.5 ...
$ routeIdx : num 0 1 2 3 4 5 6 7 8 9 ...
$ datetime_ct: POSIXct, format: "2016-06-13 06:20:00" "2016-06-13 06:28:00" "2016-06-13 06:34:00" ...
I want to interpolate between the arrival/departure times to visualize the movement of the train as I did here: https://twitter.com/0ttlngr/status/739212217489489920
I have data for one train only, therefore I have just a single group:
ice$group <- 1
I want tweenr
to interpolate linearly:
ice$ease <- "linear"
And now I use tween_elements()
to interpolate:
> tween_elements(ice, time = "datetime_ct", group = "group", ease = "ease", nframes = 100)
Error in `/.difftime`((data[[time]] - timerange[1]), framelength) :
second argument of / cannot be a "difftime" object
I wonder if it's a mistake of mine or if there's a problem with tween_elements()
.
Needed esp for list of outliers in geom_boxplot
Would it be possible to add dynamic titles to use in conjunction with gg_animate
. For example:
ts <- split(gapminder, gapminder$year)
tf <- tween_states(ts, tweenlength = 2, statelength = 1, ease = 'cubic-in-out', nframes = 50)
p <- ggplot(data = tf, aes(x = gdpPercap, y = lifeExp, size = pop, color = continent, frame = .frame)) +
geom_point() +
scale_x_log10() +
ggtitle("Title")
gg_animate(p, interval = 0.2)
Notice that this has a static Title
and then the frame
from frame = .frame
.
Hi,
In last dev version of gganimate, @dgrtwo changed gg_animate
to gganimate
with more changes on the way GIF are saved.
It is a breaking change for README.md
examples when we install with
devtools::install_github("dgrtwo/gganimate")
. We need to install last working version dgrtwo/gganimate@26ec501
with gg_animate
As it is curently Work In Progress for gganimate
, we maybe should wait for final work but as I wanted to try tweenr
I stumbled upon these non working examples.
I thought it would be valuable to report this.
I was attempting to use the tween_t functions to interpolate between positions in 3D, but there are discontinuities due to tweenr placing the key frames at separate points in the tweened sequence, even though it's all in the same tween_t()
call. You can see below that the key frames randomly switch between the 7th/13th and 8th/14th item in the sequence, and aren't consistent across columns.
set.seed(1)
vals = tweenr::tween_t(list(c(1,2,1,2),c(1,2,1,2)),n=20)
do.call(cbind,vals)
#> [,1] [,2]
#> [1,] 1.000000 1.000000
#> [2,] 1.142857 1.166667
#> [3,] 1.285714 1.333333
#> [4,] 1.428571 1.500000
#> [5,] 1.571429 1.666667
#> [6,] 1.714286 1.833333
#> [7,] 1.857143 2.000000
#> [8,] 2.000000 1.833333
#> [9,] 1.833333 1.666667
#> [10,] 1.666667 1.500000
#> [11,] 1.500000 1.333333
#> [12,] 1.333333 1.166667
#> [13,] 1.166667 1.000000
#> [14,] 1.000000 1.142857
#> [15,] 1.166667 1.285714
#> [16,] 1.333333 1.428571
#> [17,] 1.500000 1.571429
#> [18,] 1.666667 1.714286
#> [19,] 1.833333 1.857143
#> [20,] 2.000000 2.000000
which(vals[[1]] - 1 == 0)
#> [1] 1 14
which(vals[[2]] - 1 == 0)
#> [1] 1 13
vals = tweenr::tween_t(list(c(1,2,1,2),c(1,2,1,2)),n=20)
do.call(cbind,vals)
#> [,1] [,2]
#> [1,] 1.000000 1.000000
#> [2,] 1.142857 1.166667
#> [3,] 1.285714 1.333333
#> [4,] 1.428571 1.500000
#> [5,] 1.571429 1.666667
#> [6,] 1.714286 1.833333
#> [7,] 1.857143 2.000000
#> [8,] 2.000000 1.857143
#> [9,] 1.833333 1.714286
#> [10,] 1.666667 1.571429
#> [11,] 1.500000 1.428571
#> [12,] 1.333333 1.285714
#> [13,] 1.166667 1.142857
#> [14,] 1.000000 1.000000
#> [15,] 1.166667 1.166667
#> [16,] 1.333333 1.333333
#> [17,] 1.500000 1.500000
#> [18,] 1.666667 1.666667
#> [19,] 1.833333 1.833333
#> [20,] 2.000000 2.000000
which(vals[[1]] - 1 == 0)
#> [1] 1 14
which(vals[[2]] - 1 == 0)
#> [1] 1 14
vals = tweenr::tween_t(list(c(1,2,1,2),c(1,2,1,2)),n=20)
do.call(cbind,vals)
#> [,1] [,2]
#> [1,] 1.000000 1.000000
#> [2,] 1.142857 1.166667
#> [3,] 1.285714 1.333333
#> [4,] 1.428571 1.500000
#> [5,] 1.571429 1.666667
#> [6,] 1.714286 1.833333
#> [7,] 1.857143 2.000000
#> [8,] 2.000000 1.833333
#> [9,] 1.833333 1.666667
#> [10,] 1.666667 1.500000
#> [11,] 1.500000 1.333333
#> [12,] 1.333333 1.166667
#> [13,] 1.166667 1.000000
#> [14,] 1.000000 1.142857
#> [15,] 1.166667 1.285714
#> [16,] 1.333333 1.428571
#> [17,] 1.500000 1.571429
#> [18,] 1.666667 1.714286
#> [19,] 1.833333 1.857143
#> [20,] 2.000000 2.000000
which(vals[[1]] - 1 == 0)
#> [1] 1 14
which(vals[[2]] - 1 == 0)
#> [1] 1 13
vals = tweenr::tween_t(list(c(1,2,1,2),c(1,2,1,2)),n=20)
do.call(cbind,vals)
#> [,1] [,2]
#> [1,] 1.000000 1.000000
#> [2,] 1.166667 1.166667
#> [3,] 1.333333 1.333333
#> [4,] 1.500000 1.500000
#> [5,] 1.666667 1.666667
#> [6,] 1.833333 1.833333
#> [7,] 2.000000 2.000000
#> [8,] 1.833333 1.857143
#> [9,] 1.666667 1.714286
#> [10,] 1.500000 1.571429
#> [11,] 1.333333 1.428571
#> [12,] 1.166667 1.285714
#> [13,] 1.000000 1.142857
#> [14,] 1.142857 1.000000
#> [15,] 1.285714 1.166667
#> [16,] 1.428571 1.333333
#> [17,] 1.571429 1.500000
#> [18,] 1.714286 1.666667
#> [19,] 1.857143 1.833333
#> [20,] 2.000000 2.000000
which(vals[[1]] - 1 == 0)
#> [1] 1 13
which(vals[[2]] - 1 == 0)
#> [1] 1 14
Created on 2021-02-28 by the reprex package (v1.0.0)
I'm receiving the following (and similar) errors when re-running the provided examples in both gganimate and tweenr packages.
Error in .Call("_tweenr_numeric_element_interpolator", PACKAGE = "tweenr", :
"_tweenr_numeric_element_interpolator" not available for .Call() for package "tweenr"
The only difference appears to be the interpolator. I'm stumped as to how to correct this is as .Call is an internal function.
This package changed licensing some time ago without getting the consent from contributors. This was just me not being aware of the finer prints of GPL licensing (incidentallly this was also why I wanted to change it). So previous contributors (@jimhester, @QuLogic, @lgatto, @lselzer, @jpolonsky) if you are against this change, reply to this thread and I’ll make sure to undo your contributions. I’ll close this issue in a month or so and consider it resolved if no one responds
Hi I try to use the code for the dancing ball but i get the following error message. Can you help?
Executing:
convert -loop 0 -delay 6.66666666666667 Rplot1.png Rplot2.png Rplot3.png Rplot4.png Rplot5.png Rplot6.png Rplot7.png Rplot8.png
Rplot9.png Rplot10.png Rplot11.png Rplot12.png Rplot13.png Rplot14.png Rplot15.png Rplot16.png Rplot17.png Rplot18.png Rplot19.png
Rplot20.png Rplot21.png Rplot22.png Rplot23.png Rplot24.png Rplot25.png Rplot26.png Rplot27.png Rplot28.png Rplot29.png Rplot30.png
Rplot31.png Rplot32.png Rplot33.png Rplot34.png Rplot35.png Rplot36.png Rplot37.png Rplot38.png Rplot39.png Rplot40.png Rplot41.png
Rplot42.png Rplot43.png Rplot44.png Rplot45.png Rplot46.png Rplot47.png Rplot48.png Rplot49.png Rplot50.png Rplot51.png Rplot52.png
Rplot53.png Rplot54.png Rplot55.png Rplot56.png Rplot57.png Rplot58.png Rplot59.png Rplot60.png Rplot61.png Rplot62.png Rplot63.png
Rplot64.png Rplot65.png Rplot66.png Rplot67.png Rplot68.png Rplot69.png Rplot70.png Rplot71.png Rplot72.png Rplot73.png Rplot74.png
Rplot75.png Rplot76.png Rplot77.png Rplot78.png Rplot79.png Rplot80.png Rplot81.png Rplot82.png Rplot83.png Rplot84.png Rplot85.png
Rplot86.png Rplot87.png Rplot88.png Rplot89.png Rplot90.png Rplot91.png Rplot92.png Rplot93.png Rplot94.png Rplot95.png Rplot96.png
Rplot97.png Rplot98.png Rplot99.png Rplot100.png Rplot101.png Rplot102.png Rplot103.png Rplot104.png Rplot105.png Rplot106.png
Rplot107.png Rplot108.png Rplot109.png Rplot110.png Rplot111.png Rplot112.png Rplot113.png Rplot114.png Rplot115.png Rplot116.png
Rplot117.png Rplot118.png Rplot119.png Rplot120.png Rplot121.png Rplot122.png Rplot123.png Rplot124.png Rplot125.png Rplot126.png
Rplot127.png Rplot128.png Rplot129.png Rplot130.png Rplot131.png Rplot132.png Rplot133.png Rplot134.png Rplot135.png Rplot136.png
Rplot137.png Rplot138.png Rplot139.png Rplot140.png Rplot141.png Rplot142.png Rplot143.png Rplot144.png Rplot145.png Rplot146.png
Rplot147.png Rplot148.png Rplot149.png Rplot150.png Rplot151.png Rplot152.png Rplot153.png Rplot154.png Rplot155.png Rplot156.png
Rplot157.png Rplot158.png Rplot159.png Rplot160.png Rplot161.png Rplot162.png Rplot163.png Rplot164.png Rplot165.png Rplot166.png
Rplot167.png Rplot168.png Rplot169.png Rplot170.png Rplot171.png Rplot172.png Rplot173.png Rplot174.png Rplot175.png Rplot176.png
Rplot177.png Rplot178.png Rplot179.png Rplot180.png Rplot181.png Rplot182.png Rplot183.png Rplot184.png Rplot185.png Rplot186.png
Rplot187.png Rplot188.png Rplot189.png Rplot190.png Rplot191.png Rplot192.png Rplot193.png Rplot194.png Rplot195.png Rplot196.png
Rplot197.png Rplot198.png Rplot199.png Rplot200.png Rplot201.png Rplot202.png Rplot203.png Rplot204.png Rplot205.png Rplot206.png
Rplot207.png Rplot208.png Rplot209.png Rplot210.png Rplot211.png Rplot212.png Rplot213.png Rplot214.png Rplot215.png Rplot216.png
Rplot217.png Rplot218.png Rplot219.png Rplot220.png Rplot221.png Rplot222.png Rplot223.png Rplot224.png Rplot225.png Rplot226.png
Rplot227.png Rplot228.png Rplot229.png Rplot230.png Rplot231.png Rplot232.png Rplot233.png Rplot234.png Rplot235.png Rplot236.png
Rplot237.png Rplot238.png Rplot239.png Rplot240.png Rplot241.png Rplot242.png Rplot243.png Rplot244.png Rplot245.png Rplot246.png
Rplot247.png Rplot248.png Rplot249.png Rplot250.png Rplot251.png Rplot252.png Rplot253.png Rplot254.png Rplot255.png Rplot256.png
Rplot257.png Rplot258.png Rplot259.png Rplot260.png Rplot261.png Rplot262.png Rplot263.png Rplot264.png Rplot265.png Rplot266.png
Rplot267.png Rplot268.png Rplot269.png Rplot270.png Rplot271.png Rplot272.png Rplot273.png Rplot274.png Rplot275.png Rplot276.png
Rplot277.png Rplot278.png Rplot279.png Rplot280.png Rplot281.png Rplot282.png Rplot283.png Rplot284.png Rplot285.png Rplot286.png
Rplot287.png Rplot288.png Rplot289.png Rplot290.png Rplot291.png Rplot292.png Rplot293.png Rplot294.png Rplot295.png Rplot296.png
Rplot297.png Rplot298.png Rplot299.png Rplot300.png Rplot301.png Rplot302.png Rplot303.png Rplot304.png Rplot305.png Rplot306.png
Rplot307.png Rplot308.png Rplot309.png Rplot310.png Rplot311.png Rplot312.png Rplot313.png Rplot314.png Rplot315.png Rplot316.png
Rplot317.png Rplot318.png Rplot319.png Rplot320.png Rplot321.png Rplot322.png Rplot323.png Rplot324.png Rplot325.png Rplot326.png
Rplot327.png Rplot328.png Rplot329.png Rplot330.png Rplot331.png Rplot332.png Rplot333.png Rplot334.png Rplot335.png Rplot336.png
Rplot337.png Rplot338.png Rplot339.png Rplot340.png Rplot341.png Rplot342.png Rplot343.png Rplot344.png Rplot345.png Rplot346.png
Rplot347.png Rplot348.png Rplot349.png Rplot350.png Rplot351.png Rplot352.png Rplot353.png Rplot354.png Rplot355.png Rplot356.png
Rplot357.png Rplot358.png Rplot359.png Rplot360.png Rplot361.png Rplot362.png Rplot363.png Rplot364.png Rplot365.png Rplot366.png
Rplot367.png Rplot368.png Rplot369.png Rplot370.png Rplot371.png Rplot372.png Rplot373.png Rplot374.png Rplot375.png 'dancing
ball.gif'
convert: no decode delegate for this image format PNG' @ error/constitute.c/ReadImage/509. convert: no images defined
dancing ball.gif' @ error/convert.c/ConvertImageCommand/3254.
an error occurred in the conversion... see Notes in ?im.convert
Error in file(file, "rb") : cannot open the connection
In addition: Warning message:
In file(file, "rb") :
cannot open file '/Users/anabento/Desktop/dancing ball.gif': No such file or directory
Right now, setting the lower value of timerange
doesn't affect the starting point of the tween. E.g.:
library(dplyr)
library(tweenr)
df <- data.frame(time = 0:10, val = 0:10)
tw_df <- tween_appear(df, "time", timerange = c(-1, 11), nframes = 100)
filter(tw_df, time == 0, .frame == 0)
returns
time val .age .frame
1 0 0 0 0
when it should actually be returning
time val .age .frame
1 0 0 -1 0
and
tw_df <- tween_appear(df, "time", timerange = c(1, 11), nframes = 100)
filter(tw_df, time == 0, .frame == 0)
returns
time val .age .frame
1 0 0 0 0
when it should actually be returning
time val .age .frame
1 0 0 1 0
I believe this can be solved in the tween_appear
function by changing:
timepoint <- f * framelength
to
timepoint <- f * framelength + min(timerange)
In addition, I think that:
framelength <- diff(timerange)/nframes
should be changed to:
framelength <- diff(timerange)/(frames-1)
to ensure that the last frame ends exactly on the upper value of timerange
.
Of course, I might also have completely missed the point of what the code is intended to do, in which case you can safely ignore all of the above :-)
Transition polygons and path with different number of points. Saw a d3 example somewhere
This package is excellent and I'll be interested in integrating it into the gganimate package!
Would you be open to changing tween_elements
etc to take bare names instead of strings for the columns? For example, instead of
data %>%
tween_elements('time', 'group', 'ease', nframes = 100)
It could be used like:
data %>%
tween_elements(time, group, ease, nframes = 100)
This could be implemented as described here, by making two versions of the functions, e.g. tween_elements_
and tween_elements
. The advantages:
tween_elements
call, e.g. tween_elements(time = round(year, -2)...)
, or where a bare string for ease
would be interpreted as an argument (e.g. someone could just put tween_elements(...ease = "cubic-in-out"... without having to add the
ease column to the data).tween_elements_
if they wanted to provide string column namesIf you are open to this change, I would be very happy to implement it myself and submit it as a pull request
Hi Thomas,
When I try to install the tweenr package it gives me the following error msg:
install.packages("tweenr")
My session info is the following:
sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 34 (Workstation Edition)
Matrix products: default
BLAS/LAPACK: /usr/lib64/libflexiblas.so.3.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5 tcltk_4.0.5
Thanks,
Lel
I'm noticing that tween_state
calculates one fewer frame if its .data
argument is not the result of a prior "tween" than if its .data
argument is the result of a prior "tween".
For an example with three (identical) states stored in a list that is "reduced" by tween_state
with nframes=2
I'm observing no transition frame for the tween of the first two states and one transition frame for the tween of the second and third states.
> library("tweenr")
> df <- data.frame(piece_type = "pawn", color = "black",
+ x = 1.0, y = 1.0, id = 1, stringsAsFactors = FALSE)
> dfs <- list(df, df, df)
> print(dfs)
[[1]]
piece_type color x y id
1 pawn black 1 1 1
[[2]]
piece_type color x y id
1 pawn black 1 1 1
[[3]]
piece_type color x y id
1 pawn black 1 1 1
> fn <- function(df1, df2) tween_state(df1, df2, ease = 'linear', nframes = 2, id = id)
> df <- Reduce(fn, dfs)
> print(df)
piece_type color x y id .id .phase .frame
1 pawn black 1 1 1 1 raw 1
2 pawn black 1 1 1 1 raw 2
21 pawn #000000FF 1 1 1 1 transition 3
11 pawn black 1 1 1 1 raw 4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.