The Clipboard can be Your Friend

January 17, 2011
By

(This article was first published on Brock's Data Adventure » R, and kindly contributed to R-bloggers)

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 his blog: Brock's Data Adventure » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , ,

Comments are closed.