[R] problem with writing data to *.xls file
Hans-Peter Suter
gchappi at gmail.com
Fri Jan 23 13:59:03 CET 2009
> I read data from *.xls file and i did some caliculations on that data and
> now i have to create a column in the same .xls file
> i tried it with *write.xls() *but the thing is it deleted all the columns
> previously presented in that file and it created a column and inserted data
> can any one suggest what to do for this
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 )
--
Regards,
Hans-Peter
More information about the R-help
mailing list