{"id":15165868,"url":"https://github.com/milesmcbain/datapasta","last_synced_at":"2025-05-15T20:02:50.638Z","repository":{"id":11336018,"uuid":"69167057","full_name":"MilesMcBain/datapasta","owner":"MilesMcBain","description":"On top of spaghetti, all covered in cheese....","archived":false,"fork":false,"pushed_at":"2022-04-29T11:08:13.000Z","size":1845,"stargazers_count":902,"open_issues_count":33,"forks_count":59,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-13T20:47:09.814Z","etag":null,"topics":["addin","clipboard","copypaste","excel","r","tibble"],"latest_commit_sha":null,"homepage":"https://milesmcbain.github.io/datapasta/","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/MilesMcBain.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":"2016-09-25T13:48:36.000Z","updated_at":"2025-04-17T21:33:52.000Z","dependencies_parsed_at":"2022-08-02T14:30:33.253Z","dependency_job_id":null,"html_url":"https://github.com/MilesMcBain/datapasta","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesMcBain%2Fdatapasta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesMcBain%2Fdatapasta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesMcBain%2Fdatapasta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MilesMcBain%2Fdatapasta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MilesMcBain","download_url":"https://codeload.github.com/MilesMcBain/datapasta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254303119,"owners_count":22048181,"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":["addin","clipboard","copypaste","excel","r","tibble"],"created_at":"2024-09-27T04:05:19.988Z","updated_at":"2025-05-15T20:02:48.980Z","avatar_url":"https://github.com/MilesMcBain.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datapasta 3.1.1 'Leave to Simmer'\n[![r-universe status badge](https://milesmcbain.r-universe.dev/badges/datapasta)](https://milesmcbain.r-universe.dev)\n[![CRAN status.](http://www.r-pkg.org/badges/version/datapasta)](http://www.r-pkg.org/pkg/datapasta)\n[![Downloads](http://cranlogs.r-pkg.org/badges/datapasta)](https://CRAN.R-project.org/package=datapasta)\n\n\u003cimg src=\"https://raw.githubusercontent.com/milesmcbain/datapasta/master/inst/media/hex_web.png\" width=\"200\"/\u003e\n\n# The Goods\n![pow!](https://raw.githubusercontent.com/milesmcbain/datapasta/master/inst/media/tribble_paste.gif)\n\n# Introducing datapasta\n\n`datapasta` is about reducing resistance associated with copying and pasting data to and from R. It is a response to the realisation that I often found myself using intermediate programs like Sublime to munge text into suitable formats. Addins and functions in `datapasta` support a wide variety of input and output situations, so it (probably) \"just works\". Hopefully tools in this package will remove such intermediate steps and associated frustrations from our data slinging workflows.  \n\n# Prerequisites\n* Linux users will need to install either `xsel` or `xclip`. These applications provide an interface to X selections (clipboard-like).\n    - For example: `sudo apt-get install xsel` - it's 72kb...\n* Windows and MacOS have nothing extra to do.\n\n# Installation\n\n## R Universe (preferred)\n\n1. install with R universe repo:\n\n```\ninstall.packages(\n   \"datapasta\", \n   repos = c(mm = \"https://milesmcbain.r-universe.dev\", getOption(\"repos\")))\n```\n\n2. Set the keyboard shortcuts using **Tools** -\u003e **Addins** -\u003e **Browse Addins**, then click **Keyboard Shortcuts...**\n\n\n## CRAN (outdated)\n\nFor now, no further versions of `datapasta` will be going to CRAN. There are some known bugs in the CRAN version that have been fixed in `3.1.1`.\n\n1. `install.packages(\"datapasta\")`\n\n# Usage\n\n## Use with RStudio\n\n### Getting data into source\n\nAt the moment this package contains these RStudio addins that paste data to the cursor:\n\n* `tribble_paste` which pastes a table as a nicely formatted call to `tibble::tribble()`\n    - Recommend \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003et\u003c/kbd\u003e as shortcut.\n    - Table can be delimited with tab, comma, pipe or semicolon. \n* `vector_paste` which will paste delimited data as a vector definition, e.g. `c(\"a\", \"b\")` etc.\n    - Recommend \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eAlt\u003c/kbd\u003e + \u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003ev\u003c/kbd\u003e as shortcut.\n* `vector_paste_vertical` which will paste delimited data as a vertically formatted vector definition.\n    - Recommend \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003ev\u003c/kbd\u003e as shortcut \n    - example output:\n```\nc(\"Mint\",\n  \"Fedora\",\n  \"Debian\",\n  \"Ubuntu\",\n  \"OpenSUSE\")\n```\n* `df_paste` which pastes a table on the clipboard as a standard `data.frame` definition rather than a `tribble` call. This has certain advantages in the context of reproducible examples and educational posts. Many thanks to [Jonathan Carroll](https://github.com/jonocarroll) for getting this rolling and coding the bulk of the feature.\n    - Recommend \u003ckbd\u003eCtrl\u003c/kbd\u003e + \u003ckbd\u003eAlt\u003c/kbd\u003e + \u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003ed\u003c/kbd\u003e as shortcut.\n* `dt_paste` which is the same as `df_paste`, but for `data.table`.\n\n### Massaging data in source\nThere are two Addins that can help with creating and aligning data in your editor:\n\n* `Fiddle Selection` will perform magic on a selection. It can be used to: \n    - Turn raw data delimited by any combination of commas, spaces, and newlines into a `c()` expression\n    - Pivot a `c()` expr between horizontal and vertical layout.\n    - Reflow messy `tribble()` and `data.frame()` exprs.\n    - Recommend \u003ckbd\u003eCtrl\u003c/kbd\u003e +\u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003ef\u003c/kbd\u003e as shortcut.\n\n* `Toggle Vector Quotes` will toggle a `c()` expr between all elements wrapped in `\"\"` and all bare unquoted form. Handy in combination with above to save mucho keystrokes.\n    - Recommend \u003ckbd\u003eCtrl\u003c/kbd\u003e +\u003ckbd\u003eShift\u003c/kbd\u003e + \u003ckbd\u003eq\u003c/kbd\u003e as shortcut.\n\n### Getting Data out of an R session\nThere are two R functions available that accept R objects and output formatted text for pasting to a [reprex](https://github.com/tidyverse/reprex) or other application:\n\n* `dpasta` accepts tibbles, data.frames, and vectors. Data is output in a format that matches in input class. Formatted text is pasted at the cursor.\n\n* `dmdclip` accepts the same inputs as `dpasta` but inserts the formatted text onto the clipboard, preceded by 4 spaces so that is can be as pasted as a preformatted block to Github, Stackoverflow etc.\n    \n## Use with other editors\n\nThe only hard dependency of `datapasta` is `readr` for type guessing. All the above `*paste` functions can be called directly instead of as an addin, and will fall back to console output if the `rstudioapi` is not available.\n\nOn system without access to the clipboard (or without `clipr` installed) `datapasta` can still be used to output R objects from an R session. `dpasta` is probably the only function you care about in this scenario.\n\n### Custom Installation\n\n`datapasta` imports `clipr` and `rstudioapi` so as to make installation smooth and easy for most users. If you wish to avoid installing an `rstudioapi` you will never use you can use: \n\n* `install.packages(\"datapasta\", dependencies = \"Depends\")`.\n* Followed by `install.packages(\"clipr\")` to enable clipboard features. \n\n\n# Pitfalls\n\n* `tribble_paste` works well with CSVs, excel files, and html tables, but is currently brittle with respect to irregular table structures like merged cells or multi-line column headings. For some reason Wikipedia seems chock full of these. :(\n* Quoted csv data, where the quotes contain commas will not be parsed correctly.\n* Nested list columns have limited support with `tribble_paste()`/`dpasta()`. Nested lists of length 1 fail unless all are length 1 - It's complicated. You still get some output so it might be viable to fix and reflow with `Fiddle Selection`.  Tread with caution.  \n\n# Prior art\n\nThis package is made possible by [mdlincon's clipr](https://github.com/mdlincoln/clipr), and Hadley's packages [tibble](https://github.com/hadley/tibble) and [readr](https://github.com/hadley/tibble) (for data-type guessing). I especially appreciate `clipr's` thoughtful approach to the clipboard on Linux, which pretty much every other R clipboard package just nope'd out on.\n\n# Future developments\nI am interested in expanding the types of objects supported by the output functions `dpasta`. I would also like to eventually have `Fiddle Selection` to pivot function calls and named vectors. Feel free to contribute your ideas to the open issues.\n\n# Bonus\n\n0 to `datapasta` in 64 seconds via a video vignette:\n\n[![Datapasta in 64 seconds](http://img.youtube.com/vi/Sz-tEVqZh5s/0.jpg)](https://youtu.be/Sz-tEVqZh5s)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesmcbain%2Fdatapasta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilesmcbain%2Fdatapasta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilesmcbain%2Fdatapasta/lists"}