Skip to content

problem with writing data to *.xls file

3 messages · venkata kirankumar, PIKAL Petr, Hans-Peter Suter

#
Hi

It depends if you have Excel available

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

this function I use for copying object through clipboard to opened Excel 
file.

just

write.excel(someobject)
open excel list
Ctrl-V

puts an object into a list.

Regards
Petr


r-help-bounces at r-project.org napsal dne 20.01.2009 15:18:00:
and
columns
data
http://www.R-project.org/posting-guide.html
2 days later
#
You cannot insert a column in the sheet but you can write a data
matrix/frame which contains the newly calculated column.

myfile <- "test.xls"

  # read data
#dat <- read.xls( myfile )
dat <- cbind( 1:4, rep(41,4), rep(43,4) )

  # calculate and prepare full data to write
calc <- dat[,2] + 1
dat <- cbind( dat[,1], dat[,2], calc, dat[,3] )

  # write (sheet will be overwritten with new data)
#write.xls( dat, myfile )