Solution for error message in R for pasting Excel data from clipboard (pipe(‘pbpaste’) )

One of the quickest ways in R to get data into it is to copy to the clipboard then paste it into a variable.

This can be done in Windows by

read.table("clipboard", header=T)

The exact same function can be done on a MAC computer with

read.table(pipe("pbpaste"), header=T)

However, in the MAC a red warning message appears like this

Screenshot 2018-02-14 19.09.54

What seems to be happening is that R seems to read the clipboard with a missing closing line to the table. This also happens with files. Although the warning message does not seem to affect the data and can be ignored, it is annoying. So if you really want to see this message disappear, you can:

  1. copy the data from MS Excel
  2. paste into then copy the data from MS Word
  3. paste into R with read.table(pipe("pbpaste"), header=T)

This seems to do the trick when nothing else seems to work. While this is not the most elegant and ideal solution, it is a solution. Enjoy.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s