Skip to content

Easy cut & paste from Excel to R?

5 messages · Jose Quesada, roger bos, Gabor Grothendieck +1 more

#
Sorry to revive and old topic, but writing to the clipboard seems to
have a problem for me: column names are ignored. Example:

# ~~~~~~~~~~~~~~~~~~~~~~~
# write.clipboard
# ~~~~~~~~~~~~~~~~~~~~~~~
write.clipboard = function(obj) {
	write.table(obj, file("clipboard"), sep="\t", row.names=F, col.names=T)
}

a= matrix(1:4,2,2)
colnames(a) = c("a", "b")

write.clipboard(a)
a = as.data.frame(a)
write.clipboard(a)

both attempts will paste the date without column names.
Any idea why?

Thanks,
-Jose
On 2/16/05, Werner Wernersen <pensterfuzzer at yahoo.de> wrote:
--
Jose Quesada, PhD.

j.quesada at warwick.ac.uk				ESRC Postdoctoral Fellow
http://lsa.colorado.edu/~quesadaj		Dept. of PSychology
http://www.andrew.cmu.edu/~jquesada		University of Warwick
office H114						Phone: +44 024 765 23 759
Coventry, UK
#
See:

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/26922.html
On 9/29/05, Jose Quesada <quesada at gmail.com> wrote:
#
Hi

Works for me.

write.excel <- function (tab, ...) write.table(tab, "clipboard", sep 
= "\t", row.names = F)

write.excel(a)

from your example shows in Excel after ctrl-V as a table with names.

HTH

Petr
On 29 Sep 2005 at 12:12, Jose Quesada wrote:
Date sent:      	Thu, 29 Sep 2005 12:12:00 +0100
From:           	Jose Quesada <quesada at gmail.com>
To:             	Werner Wernersen <pensterfuzzer at yahoo.de>
Copies to:      	r-help at stat.math.ethz.ch
Subject:        	Re: [R] Easy cut & paste from Excel to R?
Send reply to:  	Jose Quesada <quesada at gmail.com>
	<mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe>
	<mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>
Petr Pikal
petr.pikal at precheza.cz