Skip to content
Back to formatted view

Raw Message

Message-ID: <47fce0650901230459r3cf6618ie56be4a4894b3fe1@mail.gmail.com>
Date: 2009-01-23T12:59:03Z
From: Hans-Peter Suter
Subject: problem with writing data to *.xls file
In-Reply-To: <27f678620901200618i1883fb9fh270c91021687b018@mail.gmail.com>

> 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