Join GitHub today
Read from clipboard #656
I was wondering if reading from a clipboard will be supported in the future? There was an earlier issue which provided a work-around, but it doesn't seem to work anymore.
read_csv can only read from a binary connection while the connection itself only allows for non-binary connections.
Using the base functions, this is quite straightforward.
Here's another workaround that uses clipr and works today:
library(tidyverse) library(clipr) txt <- "v1,v2\n1.1,1.2\n2.1,2.2" read_csv(txt) #> # A tibble: 2 × 2 #> v1 v2 #> <dbl> <dbl> #> 1 1.1 1.2 #> 2 2.1 2.2 write_clip(txt) read_csv(paste(read_clip(), collapse = "\n")) #> # A tibble: 2 × 2 #> v1 v2 #> <dbl> <dbl> #> 1 1.1 1.2 #> 2 2.1 2.2
@jimhester That's a great suggestion. But why not comply with base R, so
would internally be treated as
read_csv(paste(readLines(file("clipboard"))), collapse = "\n"))
It think it is far more convenient for users, and should not be too much work for the