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?
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?
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")