Last active
December 14, 2015 18:19
-
-
Save mrdwab/5128419 to your computer and use it in GitHub Desktop.
Read pasted output at Stack Overflow into R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read.so <- function(sep = "", header = TRUE, out = "mydf") { | |
OS <- ifelse(Sys.info()["sysname"] == "Darwin", "Mac", "others") | |
temp <- switch( | |
OS, | |
Mac = { | |
suppressWarnings( | |
read.table(text = gsub("^#", "", pipe("pbpaste")), header = header, | |
stringsAsFactors = FALSE, sep = sep)) | |
}, | |
others = { | |
suppressWarnings( | |
read.table(text = gsub("^#", "", readLines("clipboard")), | |
header = header, stringsAsFactors = FALSE, sep = sep)) | |
}) | |
assign(out, temp, envir = .GlobalEnv) | |
message("data.frame ", dQuote(out), " created in your workspace") | |
temp | |
} |
Author
mrdwab
commented
Mar 10, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment