{"id":23592634,"url":"https://github.com/chris1221/ggsource","last_synced_at":"2025-11-04T10:30:29.895Z","repository":{"id":47137595,"uuid":"397310117","full_name":"Chris1221/ggsource","owner":"Chris1221","description":"Easily open the file used to generate an exported PDF from R / ggplot2.","archived":false,"fork":false,"pushed_at":"2021-09-12T15:07:21.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-27T08:16:19.084Z","etag":null,"topics":["exiftool","ggplot2","pdf"],"latest_commit_sha":null,"homepage":"","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/Chris1221.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2021-08-17T15:43:28.000Z","updated_at":"2022-01-06T15:44:08.000Z","dependencies_parsed_at":"2022-07-22T19:02:22.693Z","dependency_job_id":null,"html_url":"https://github.com/Chris1221/ggsource","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris1221%2Fggsource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris1221%2Fggsource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris1221%2Fggsource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chris1221%2Fggsource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chris1221","download_url":"https://codeload.github.com/Chris1221/ggsource/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239432734,"owners_count":19637798,"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":["exiftool","ggplot2","pdf"],"created_at":"2024-12-27T08:14:58.435Z","updated_at":"2025-11-04T10:30:29.831Z","avatar_url":"https://github.com/Chris1221.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ggsource [![CircleCI](https://circleci.com/gh/Chris1221/ggsource/tree/main.svg?style=svg)](https://circleci.com/gh/Chris1221/ggsource/tree/main)\n\nRecover source code from exported PDFs. Use `ggsource::ggsave` instead of `ggplot2::ggsave`, and you can use `ggsource::ggsource` to quickly re-open whatever file was used to generate the plot in Rstudio.\n\nhttps://user-images.githubusercontent.com/8516981/132992508-0dd4ee74-10e4-4d60-b80b-9918bab9535c.mp4\n\n## 🛠️ Installation \n\n```{r}\ndevtools::install_github(\"Chris1221/ggsource\")\nlibrary(ggsource)\n```\n\n\u003e Note: The package intentionally masks `ggplot2::ggsave`. There's no reason to use `ggplot2::ggsave` if you're using `ggsource`, as the export functionality is the same and, on error, `ggsource` defaults to `ggplot2::ggsave` anyway.\n\nYou must also install `ExifTool` if it not already installed on your system. See [here](https://exiftool.org/install.html) for how to do that. \n\n## 📊 Usage\n\nThe default way of using `ggsource` is within RStudio. You won't need to specify any additional arguments, and `ggsource::ggsave` will function as a drop in replacement of `ggplot2::ggsave` with the additional benefit of being able to use `ggsource::ggsource` to re-open the file. \n\nHowever, you can also customise the package to your particular set up, whether or not it revolves around the rstudioapi. \n\n#### Option 1: Within RStudio\n\nOpen a file (`my_plot.R`) in RStudio and create a plot. Save it using `ggsource::ggsave` (which will automatically mask `ggplot2::ggsave`).\n\n`my_plot.R`: \n\n```{R}\nlibrary(ggplot2)\np = ggplot(mpg, aes(displ, hwy, colour = class)) + \n  geom_point()\n\nggsave(\"my_plot.pdf\", p)\n```\n\nNow at any point in the future, you can re-open `my_plot.R` with `ggsource`. \n\n```{R}\nggsource(\"my_plot.pdf\")\n```\n\nThis will open `my_plot.R` in RStudio.\n\n#### Option 2: Outside of RStudio\n\n`ggsource::ggsave` uses the `rstudioapi` to automatically detect the open file path. To override this, you can specify the scriptname (or arbitrary string, `ggsource::ggsave` doesn't care) that you want to save within the PDF. `ggsource::ggsource` will then just return the path that you gave it in the first place. \n\n```{R}\nggsave(\"my_plot.pdf\", p, scriptname = \"my_plot.R\")\nggsource(\"my_plot.pdf\", interactive = FALSE)\n```\n\nWill return `my_plot.R`. \n\n## ❓ FAQ\n\n\u003e How does this work?\n\nPDF is a very flexible document format. It supports the addition of arbitrary tags that can contain any kind of metadata. We define a new meta tag that contains the name of the file currently open in RStudio.\n\n\u003e Will this work with PNG / TIFF / JPG?\n\nNo. Only PDF.\n\n\u003e ExifTool is not installing correctly, can you help?\n\nNo. There is extensive documentation on how to install the program [here](https://exiftool.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris1221%2Fggsource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchris1221%2Fggsource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchris1221%2Fggsource/lists"}