R data.table fread from clipboard

I want to create an excel-R :: data.table interface. I would like to ask how you can use the fread function with the clipboard. The following code works well, but I would prefer to use fread instead of read.table (to play a copy of some table in the excel file and execute the command above in R):

data.table(read.table("clipboard",sep="\t",header=TRUE))

I tried to declare a connection to the clipboard, but so far I can not get it to work. Also, as stated in the fread function documentation, this will change, and some things may be deprecated, so it would be nice to have a solution that won't expire in the near future. Are there any restrictions for the clipboard / fread? e.g. 65,000 lines or some other memory limit?

I would also suggest extending the data.table :: fread function to accept the default clipboard, since it currently works with read.table.

thanks

+4
source share
1 answer

freaddoesn't seem to have this feature, but for limited use you can easily write your own wrapper for it. Something in the following order may help you get started:

freadClip <- function(...) {
  X <- tempfile()
  writeLines(readLines("clipboard"), X)
  fread(X, ...)
}

Using will simply copy cells from your Excel worksheet, switch to R and type freadClip().

. , , - - Excel R. , "clipboard" 65 . , .

+5

All Articles