Friday, October 16, 2015

Read table from clipboard into R

This awesome function is from the psych package.

read.clipboard              package:psych              R Documentation

shortcut for reading from the clipboard

Description:

     Input from the clipboard is easy but a bit obscure, particularly
     for Mac users. This is just an easier way to do so.  Data may be
     copied to the clipboard from Exel spreadsheets, csv files, or
     fixed width formatted files and then into a data.frame. Data may
     also be read from lower (or upper) triangular matrices and filled
     out to square matrices.

Usage:

     read.clipboard(header = TRUE, ...)   #assumes headers and tab or space delimited
     read.clipboard.csv(header=TRUE,sep=',',...)   #assumes headers and comma delimited
     read.clipboard.tab(header=TRUE,sep='\t',...)   #assumes headers and tab delimited
      #read in a matrix given the lower off diagonal
      read.clipboard.lower(diag=TRUE,names=FALSE,...)
      read.clipboard.upper(diag=TRUE,names=FALSE,...)

0 comments: