Last active
April 10, 2016 17:27
-
-
Save tukachev/4e8aa973e30bbd1f46e29b1bffe71be7 to your computer and use it in GitHub Desktop.
clipboard in linux: copy&paste
This file contains 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
# only works in linux | |
# Install xclip first | |
# $ sudo apt-get install xclip | |
# write to clipboard | |
wclip <- function(x, sep="\t", row.names=FALSE, col.names=TRUE){ | |
con <- pipe("xclip -selection clipboard -i", open="w") | |
write.table(x, con, sep=sep, row.names=row.names, col.names=col.names) | |
close(con) | |
} | |
#read from clipboard | |
rclip <- function(){ | |
con <- pipe("xclip -selection clipboard -o") | |
d <- read.delim2(con) | |
return(d) | |
close(con) | |
} | |
# Example | |
wclip(1:10) | |
wclip(letters) | |
wclip(matrix(1:15, nrow = 5)) | |
data <- rclip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment