psych (version 1.0-17)

read.clipboard: shortcut for reading from the clipboard


input from the keyboard is easy but a bit obscure, particularly for Mac users. This is just an easier mnemonic to do so.


read.clipboard(header = TRUE, ...) <- read.clipboad() #assumes headers and tab delimited <- read.clipboard.csv() #assumes heades and comma delimited


Does the first row have variable labels
Other parameters to pass to read


  • the contents of the clipboard.


A typical session of R might involve data stored in text files, generated on line, etc. Although it is easy to just read from a file (particularly if using file.locate(), copying from the file to the clipboard and then reading from the clipboard is also very convenient (and somewhat more intuitive to the naive user.)


Run this code <- read.clipboad() <- read.clipboard.csv()

## The function is currently defined as
function(header=TRUE,...) {
    MAC<[1]=="Darwin"    #are we on a Mac using the Darwin system?
   if (!MAC ) {if (header) read.clipboard<-read.table(file("clipboard"),header=TRUE,...)
            else read.clipboard<-read.table(file("clipboard"),...) }
    else {
   if (header) read.clipboard<-  read.table(pipe("pbpaste"),header=TRUE,...)
   else read.clipboard<- read.table(pipe("pbpaste"),...)}

Run the code above in your browser using DataCamp Workspace