Importing data from Mac OS X clipboard into R studio

At first I thought importing data from the clipboard was only working in Windows using the well known



df <- read.table(file='clipboard', sep='\t')

But couldn’t find a way that would work, so I used to do it the dummy way (i.e. save each .xls as .csv)

Turns out it could be done using pipe files, knowing that “pbpaste” corresponds to Mac’s clipboard pipe file:

df <- read.table(pipe('pbpaste'), sep='\t', header=T)

And that’s it!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s