read.clipboard {psych}R Documentation

shortcut for reading from the clipboard

Description

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

Usage

read.clipboard(header = TRUE, ...)

#my.data <- read.clipboad()         #assumes headers and tab delimited
#my.data <- read.clipboard.csv()     #assumes heades and comma delimited

Arguments

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

Details

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.)

Value

the contents of the clipboard.

Author(s)

William Revelle

Examples

#my.data <- read.clipboad()
#my.data <- read.clipboard.csv()

## The function is currently defined as
function(header=TRUE,...) {
    MAC<-Sys.info()[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"),...)}
   }

[Package psych version 1.0-18 Index]