How to import data from the clibboard to a data-frame in R

4

One of the advantages of using spreadsheet is that we can import data from the clipboard.

Is there any way to do this in R?

    
asked by anonymous 14.09.2014 / 17:17

1 answer

3

Yes, it is possible. But there are differences in Windows and Mac:

In Windows:

You can use the readClipboard() function.

x <- readClipboard()

This will paste the clipboard data as text into x. If the clipboard data is tabular (a table, for example), you can use the read.table()

x <- read.table(file = "clipboard", sep = "\t")

On Mac:

On the Mac, you will use the pipe function along with read.table .

x <- read.table(pipe("pbpaste"), sep="\t")
    
14.09.2014 / 17:26