From 0aec40e8bb1144c836f0ede3248b2950e6637f5a Mon Sep 17 00:00:00 2001 From: "Thomas J. Leeper" Date: Tue, 22 Oct 2013 22:34:06 +0200 Subject: [PATCH] Added copy to clipboard for windows --- reproduce.R | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/reproduce.R b/reproduce.R index c239f18..3dda7cc 100644 --- a/reproduce.R +++ b/reproduce.R @@ -255,10 +255,14 @@ reproduce <- function(x, rows=10, head=NA, cols=NA, clipboard=TRUE, whole=FALSE, ret <- gsub(pattern, "", ret) # if on Mac OSX and flagged to true, then copy to clipboard - if(clipboard && Sys.info()[['sysname']] == "Darwin") { - con <- pipe("pbcopy", "w") - writeLines(ret, con) - close(con) + if(clipboard){ + if(Sys.info()[['sysname']] == "Darwin") { + con <- pipe("pbcopy", "w") + writeLines(ret, con) + close(con) + } + else if(Sys.info()[['sysname']] == "Windows") + writeLines(ret,'clipboard') } if (verbose) { @@ -269,7 +273,7 @@ reproduce <- function(x, rows=10, head=NA, cols=NA, clipboard=TRUE, whole=FALSE, ln <- function() cat(" ==X", rep("=", 62), "X==\n", sep="") ln() cat({if (clipboard) "" else rep(" ", 18)}, sep="") - cat(" Copy+Paste this part.", ifelse(clipboard, "(If on a Mac, it is already copied!)\n", "\n")) + cat(" Copy+Paste this part.", ifelse(clipboard, "(If on a Mac or Windows, it is already copied!)\n", "\n")) ln() cat("\n", ret, "\n\n") ln()