Skip to content
Prev 167960 / 398503 Next

problem with writing data to *.xls file

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 )