The Clipboard can be Your Friend

[This article was first published on Brock's Data Adventure » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

One of the features I feel that I don’t leverage enough, particularly for ad-hoc questions, is the clipboard feature  in R. I know there are many ways to use it –  as I have been exposed to a few –  but the example below, even without context, should get you thinking about how awesome R really is.  Essentially, think of a vector in R as equivalent to a column of data in Excel or SPSS and you are good to go.

your.vector <- readClipboard()

I found the code snippet here and started running.  If you select a column of your data, you can piece together a dataset from the Internet VERY QUICKLY simply by creating new objects (e.g. your.vector2).

Routinely, I find the need to grab data quickly from the world wide interwebs, but don’t have the ability to write a script to parse it quickly .  Lately, I simply copy the data I need into Excel, clean it quickly,  select my columns one by one and to piece the data back together inside R.

If you feel that you will need this hacked together dataframe later, simply save it as an *.Rdata file and call it a night.

Filed under: How-to, R, Uncategorized Tagged: Copy Clipboard in R, Data management, R, SPSS

To leave a comment for the author, please follow the link and comment on their blog: Brock's Data Adventure » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)