Hi all, 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 and i have to insert the data in to the consicutive rows related to the previous data 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 thanks in advance [[alternative HTML version deleted]]
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:> Hi all, > I read data from *.xls file and i did some caliculations on that dataand> now i have to create a column in the same .xls file > and i have to insert the data in to the consicutive rows related to the > previous data > i tried it with *write.xls() *but the thing is it deleted all thecolumns> previously presented in that file and it created a column and inserteddata> can any one suggest what to do for this > > thanks in advance > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
> 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 thisYou 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