{"id":16569172,"url":"https://github.com/thebioengineer/camcorder","last_synced_at":"2025-04-10T01:15:12.203Z","repository":{"id":45401069,"uuid":"285328936","full_name":"thebioengineer/camcorder","owner":"thebioengineer","description":"Record plots generated during an R session and replay as a gif!","archived":false,"fork":false,"pushed_at":"2024-01-12T16:07:06.000Z","size":46940,"stargazers_count":210,"open_issues_count":9,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T01:15:02.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://thebioengineer.github.io/camcorder/","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/thebioengineer.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}},"created_at":"2020-08-05T15:21:17.000Z","updated_at":"2025-03-09T20:26:34.000Z","dependencies_parsed_at":"2024-01-12T21:27:56.146Z","dependency_job_id":null,"html_url":"https://github.com/thebioengineer/camcorder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebioengineer%2Fcamcorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebioengineer%2Fcamcorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebioengineer%2Fcamcorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebioengineer%2Fcamcorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thebioengineer","download_url":"https://codeload.github.com/thebioengineer/camcorder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137891,"owners_count":21053775,"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","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":[],"created_at":"2024-10-11T21:12:37.109Z","updated_at":"2025-04-10T01:15:12.179Z","avatar_url":"https://github.com/thebioengineer.png","language":"R","funding_links":[],"categories":["Presentation, composition and scales"],"sub_categories":[],"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  warning = FALSE,\n  message = FALSE\n)\n```\n\n\n# camcorder \u003cimg src='man/figures/logo.png' align=\"right\" height=\"200\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![Codecov test coverage](https://codecov.io/gh/thebioengineer/camcorder/branch/main/graph/badge.svg)](https://app.codecov.io/gh/thebioengineer/camcorder?branch=main)\n[![R-CMD-check](https://github.com/thebioengineer/camcorder/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/thebioengineer/camcorder/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\n`{camcorder}` is an an R package to track and automatically save graphics generated with `{ggplot2}` that are created across one or multiple sessions with the eventual goal of creating a GIF showing all the plots saved sequentially during the design process. \n\nAfter installation, the package enables you to:\n\n-  save a ggplot automatically every time you run `ggplot()` in any format with given specifications\n-  generate a GIF that showcases every step of the design process using those image files\n-  inspect the ggplot output directly with your specifications in the RStudio IDE—you'll get what you see[^f1]\n\n[^f1]: In case you are saving to PDF, the file will automatically open in your default PDF viewer.\n\n## Installation\n\nCurrently {camcorder} is only available on GitHub, and can be installed using the following command.\n\n```{r install, eval=FALSE}\n# install.packages(\"camcorder\")\nremotes::install_github(\"thebioengineer/camcorder\")\n```\n\n## Goal End Product\n\nThe idea of tracking your plots as part of your development process and generating a making-of movie was popularized by two contributors to this project: Georgios Karamanis and Cédric Scherer. They have wowed the R community weekly with their \"how its made\" videos. Below are a few examples of the goal end products.\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ci\u003e\u003ca href = 'https://twitter.com/cedscherer/status/1281653392859820032'\u003eTidyTuesday 2020/28\u003c/a\u003e\u003cbr\u003eby Cédric Scherer\u003c/i\u003e\u003c/p\u003e\n\u003cimg src = \"man/figures/cscherer_coffee_ratings.gif\" height = \"350\"\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cp\u003e\u003ci\u003e\u003ca href = 'https://mobile.twitter.com/geokaramanis/status/1248147973206413312'\u003eTidyTuesday 2020/15\u003c/a\u003e\u003cbr\u003eby Georgios Karamanis\u003c/i\u003e\u003c/p\u003e\n\u003cimg src = \"man/figures/gkaramanis_tour_de_france.gif\" height = \"350\"\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\n## How To\n\nTo get started, load {camcorder} and initialize recording using the `gg_record()` function.\nThis function has several options, such as where to save the recordings, device to use to save the recordings, and the height/width of the image to create. By default it will save to a temporary directory so recordings will go away once the R session is closed.\n\n```{r setup}\nlibrary(ggplot2)\nlibrary(camcorder)\n\ngg_record(\n  dir = file.path(tempdir(), \"recording100\"), # where to save the recording\n  device = \"png\", # device to use to save images\n  width = 4,      # width of saved image\n  height = 6,     # height of saved image\n  units = \"in\",   # units for width and height\n  dpi = 300       # dpi to use when saving image\n)\n```\n\nOnce the recorder is initialized, any ggplot that is made and printed will be automatically (or *automagically*[^f2]) recorded.\n\n[^f2]: A previous typo but actually it fits quite well.\n\n```{r plots-plots-plots, results = \"hide\"}\nggplot(mtcars, aes(x = mpg, y = hp)) +\n  geom_point()\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_point(aes(shape = as.factor(gear)))\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_point(aes(color = as.factor(gear)))\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_point(aes(color = as.factor(gear))) +\n  geom_path()\n\nggplot(mtcars, aes(x = mpg, y = hp)) +\n  geom_point(aes(color = disp)) +\n  geom_smooth()\n\nggplot(mtcars, aes(x = mpg, y = hp)) +\n  geom_smooth() +\n  geom_point(aes(color = disp))\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_smooth() +\n  geom_point(aes(color = disp)) +\n  scale_color_viridis_c() +\n  theme_light()\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_smooth() +\n  geom_point(aes(color = disp)) +\n  scale_color_viridis_c() +\n  theme_light() +\n  labs(\n    title = \"MPG vs Horse Power!\",\n    subtitle = \"Power and economy, the classic compromise!\"\n  )\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_smooth() +\n  geom_point(aes(color = disp)) +\n  scale_color_viridis_c() +\n  theme_light(base_family = \"Roboto Mono\") +\n  labs(\n    title = \"MPG vs Horse Power!\",\n    subtitle = \"Power and economy, the classic compromise!\"\n  )\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_smooth() +\n  geom_point(aes(color = disp)) +\n  scale_color_viridis_c() +\n  theme_light(base_family = \"Roboto Mono\") +\n  labs(\n    title = \"MPG vs Horse Power!\",\n    subtitle = \"Power and economy, the classic compromise!\", \n    x = \"Efficiency (Miles/Gallon)\",\n    y = \"Power (Horsepower)\",\n    color = \"Displacement\\n(Cubic Inch)\"\n  )\n```\n\nIf at any point, that you want to save your plots in a different format than what the recorder was initialized with this can be done through the `gg_resize_film()` function. This will set the size and dpi of all plots going forward.\n\n```{r resize}\ngg_resize_film(\n  height = 4,\n  width = 6,\n  units = \"in\",\n  dpi = 350\n)\n```\n\n```{r plots-plots-plots-2, results = \"hide\"}\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_smooth() +\n  geom_point(aes(color = disp)) +\n  scale_color_viridis_c() +\n  theme_light(base_family = \"Roboto Mono\") +\n  labs(\n    title = \"MPG vs Horse Power!\",\n    subtitle = \"Power and economy, the classic compromise!\", \n    x = \"Efficiency (Miles/Gallon)\",\n    y = \"Power (Horsepower)\",\n    color = \"Displacement\\n(Cubic Inch)\"\n  ) +\n  theme(\n    plot.title.position = \"plot\",\n    plot.title = element_text(face = \"bold\")\n  )\n\nggplot(mtcars, aes(x = mpg, y = hp)) + \n  geom_smooth() +\n  geom_point(aes(color = disp)) +\n  scale_color_viridis_c() +\n  theme_light(base_family = \"Roboto Mono\")  +\n  labs(\n    title = \"MPG vs Horse Power!\",\n    subtitle = \"Power and economy, the classic compromise!\", \n    x = \"Efficiency (Miles/Gallon)\",\n    y = \"Power (Horsepower)\",\n    color = \"Displacement\\n(Cubic Inch)\"\n  ) +\n  theme(\n    plot.title.position = \"plot\",\n    plot.title = element_text(face = \"bold\"),\n    panel.background = element_rect(colour = \"turquoise\", fill = \"turquoise\")\n  )\n```\n\nFinally, to generate the final GIF, use the `gg_playback()` function.\nThe user can define:\n  - where the final GIF gets saved by setting the `name` argument,\n  - duration of the first and last images with `first_image_duration` or `last_image_duration`\n  - delay between frames in seconds with `frame_duration`\n\n\n```{r create-gif, eval=FALSE}\ngg_playback(\n  name = file.path(tempdir(), \"recording\", \"vignette_gif.gif\"),\n  first_image_duration = 5,\n  last_image_duration = 15,\n  frame_duration = .4,\n  image_resize = 800\n)\n```\n\nOnce rendering is complete, a GIF is opened in your viewer.\n\n![](man/figures/vignette_gif.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebioengineer%2Fcamcorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebioengineer%2Fcamcorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebioengineer%2Fcamcorder/lists"}