{"id":13788934,"url":"https://github.com/thomasp85/tweenr","last_synced_at":"2025-10-08T21:37:13.129Z","repository":{"id":3921159,"uuid":"51333413","full_name":"thomasp85/tweenr","owner":"thomasp85","description":"Interpolate your data","archived":false,"fork":false,"pushed_at":"2024-02-28T14:28:52.000Z","size":2956,"stargazers_count":399,"open_issues_count":3,"forks_count":43,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-09-08T13:04:01.726Z","etag":null,"topics":["animation","plotting","rstats","transition","tweening"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasp85.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-02-08T22:57:29.000Z","updated_at":"2025-08-28T20:35:16.000Z","dependencies_parsed_at":"2022-08-06T14:15:40.606Z","dependency_job_id":"61b78868-9349-483e-8658-0c337c7d83fd","html_url":"https://github.com/thomasp85/tweenr","commit_stats":{"total_commits":140,"total_committers":11,"mean_commits":"12.727272727272727","dds":0.07857142857142863,"last_synced_commit":"2c893a1a484c57f66e14ca05746241e8d39c87c2"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/thomasp85/tweenr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Ftweenr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Ftweenr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Ftweenr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Ftweenr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasp85","download_url":"https://codeload.github.com/thomasp85/tweenr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasp85%2Ftweenr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000702,"owners_count":26082838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","plotting","rstats","transition","tweening"],"created_at":"2024-08-03T21:00:56.154Z","updated_at":"2025-10-08T21:37:13.088Z","avatar_url":"https://github.com/thomasp85.png","language":"R","funding_links":[],"categories":["R","ggplot"],"sub_categories":["Animations"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  dev = 'jpeg',\n  ffmpeg.format='gif',\n  interval = 1/15\n)\nlibrary(magrittr)\n```\n\n# tweenr \u003cimg src=\"man/figures/logo.png\" align=\"right\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/thomasp85/tweenr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/thomasp85/tweenr/actions/workflows/R-CMD-check.yaml)\n[![CRAN\\_Release\\_Badge](http://www.r-pkg.org/badges/version-ago/tweenr)](https://CRAN.R-project.org/package=tweenr) [![CRAN\\_Download\\_Badge](http://cranlogs.r-pkg.org/badges/tweenr)](https://CRAN.R-project.org/package=tweenr)\n\u003c!-- badges: end --\u003e\n\n## What is this?\n`tweenr` is a package for interpolating data, mainly for animations. It provides\na range of functions that take data of different forms and calculate \nintermediary values. It supports all atomic vector types along with `factor`, \n`Date`, `POSIXct`, characters representing colours, and `list`. `tweenr` is used \nextensibly by [`gganimate`](https://github.com/thomasp85/gganimate) to create\nsmooth animations, but can also be used by itself to prepare data for animation\nin another framework.\n\n## How do I get it?\n`tweenr` is available on CRAN and can be installed with \n`install.packages('tweenr')`. In order to get the development version you can\ninstall it from github with `devtools`\n\n```{r, eval=FALSE}\n#install.packages('devtools')\ndevtools::install_github('thomasp85/tweenr')\n```\n\n## An example\nFollowing is an example of using the pipeable `tween_state()` function with our\nbelowed iris data:\n\n```{r, fig.show='animate', interval=1/10, message=FALSE, cache=TRUE}\nlibrary(tweenr)\nlibrary(ggplot2)\n\n# Prepare the data with some extra columns\niris$col \u003c- c('firebrick', 'forestgreen', 'steelblue')[as.integer(iris$Species)]\niris$size \u003c- 4\niris$alpha \u003c- 1\niris \u003c- split(iris, iris$Species)\n\n# Here comes tweenr\niris_tween \u003c- iris$setosa %\u003e% \n  tween_state(iris$versicolor, ease = 'cubic-in-out', nframes = 30) %\u003e% \n  keep_state(10) %\u003e% \n  tween_state(iris$virginica, ease = 'elastic-out', nframes = 30) %\u003e% \n  keep_state(10) %\u003e% \n  tween_state(iris$setosa, ease = 'quadratic-in', nframes = 30) %\u003e% \n  keep_state(10)\n\n# Animate it to show the effect\np_base \u003c- ggplot() + \n  geom_point(aes(x = Petal.Length, y = Petal.Width, alpha = alpha, colour = col, \n                 size = size)) + \n  scale_colour_identity() +\n  scale_alpha_identity() + \n  scale_size_identity() + \n  coord_cartesian(xlim = range(iris_tween$Petal.Length), \n                  ylim = range(iris_tween$Petal.Width))\niris_tween \u003c- split(iris_tween, iris_tween$.frame)\nfor (d in iris_tween) {\n  p \u003c- p_base %+% d\n  plot(p)\n}\n```\n\n## Other functions\nBesides the `tween_state()`/`keep_state()` combo showcased above, there are a\nslew of other functions meant for data in different formats\n\n**`tween_components`** takes a single data.frame, a vector of ids identifying\nrecurrent elements, and a vector of timepoints for each row and interpolate each\nelement between its specified time points.\n\n**`tween_events`** takes a single data.frame where each row encodes a single \nunique event, along with a start, and end time and expands the data across a\ngiven number of frames.\n\n**`tween_along`** takes a single data.frame along with an id and timepoint \nvector and calculate evenly spaced intermediary values with the possibility of \nkeeping old values at each frame.\n\n**`tween_at`** takes two data.frames or vectors along with a numeric vector \ngiving the interpolation point between the two data.frames to calculate.\n\n**`tween_fill`** fills missing values in a vector or data.frame by interpolating\nbetween previous and next non-missing elements\n\n## Easing\nIn order to get smooth transitions you'd often want a non-linear interpolation.\nThis can be achieved by using an easing function to translate the equidistant \ninterpolation points into new ones. `tweenr` has support for a wide range of \ndifferent easing functions, all of which can be previewed using `display_ease()`\nas here where the popular *cubic-in-out* is shown:\n\n```{r, dev='png'}\ntweenr::display_ease('cubic-in-out')\n```\n\n## Spatial interpolations\nThe purpose of `tweenr` is to interpolate values independently. If paths and \npolygons needs to be transitioned the \n[`transformr`](https://github.com/thomasp85/transformr) package should be used\nas it expands tweenr into the spatial realm\n\n```{r, echo=FALSE}\npath \u003c- dirname(knitr::fig_path())\nanimations \u003c- list.files(path, pattern = 'README-.*.gif')\nfor (file in animations) {\n  files \u003c- list.files(path, pattern = paste0(sub('.gif', '', file), '.*jpeg'), full.names = TRUE)\n  unlink(files)\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasp85%2Ftweenr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasp85%2Ftweenr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasp85%2Ftweenr/lists"}