Noodles, Code and Company
Not all of us have the privilege of quitting our consulting jobs and jetting off to Italy to play chef (taken from a true story), but that doesn’t mean we can’t roll out handmade pasta in our kitchens. And if that task seems too outside the realm of possibility, there’s a package in R called “datapasta” that’s calling all of our names. I took a taste myself just now and detailed the results of my journey below:
Prepping Your Environment
First as always, we download and call the necessary packages.
install.packages("datapasta")
library(datapasta)
install.packages("tibble")
library(tibble)
Then go to the tool menu in RStudio to continue the process.
Click on tools in the upper menu, then “add-ins”, then “browse add-ins.” You’ll see a bunch of suggested commands, but that’s not where you go. Click on “Keyboard Shortcuts” and you’ll see a new menu with blank spaces in the “shortcuts” column. Make up a shortcut for “Paste as Tibble,” and you’re good to go. Mine was “Shift+T” but it can be anything you want.
Pasting the Data
There have been plenty of times, especially throughout my MBA career, when I found a table from a case study online and wished it could magically transport itself into R. I didn’t know about datapasta then, but that’s exactly what the package is for.
Keep in mind: many tables will give you an error if RStudio cannot read the text. You’re going to want to choose a simple table with one line of headings and you may have to try out a few before you get a hit.
When you find a table you want, copy it to your clipboard as you would normally and re-open RStudio. Go to your console and perform your shortcut (for me Shift+T). Your table will copy and paste into your console and if you assign it as shown below, you will see the tibble pop up neatly in your environment for further usage.
tibble <- (Shift+T)
Below is the final product shown in my display window. This neat little trick is bound to save us all some time when pursuing our future projects.
Like what you saw here?
I may not have talked enough about pasta, but I hope this package opens up new avenues for your data collection. And if this tutorial proved useful to you, please support the creation of future package dives by becoming a patron of DiKayo Data on Patreon!