Dear all, I would like to import a range of cells (e.g. F10:K234) from an Excel worksheet to R. I have looked for documentation on RODBC and RDCOMClient but I was not able to find enough information to solve my problem and all the examples I have seen were dealing with an entire worksheet, not a range of cells. Thanks, Jean-Noel Jean-Noel Candau INRA - Unit? de Recherches Foresti?res M?diterran?ennes Avenue A. Vivaldi 84000 AVIGNON Tel: (33) 4 90 13 59 22 Fax: (33) 4 90 13 59 59
Hi What about to copy a range, paste it to notepad, save it as a *.txt file and read with read.delim(). Cheers Petr On 2 Mar 2004 at 10:10, Jean-Noel wrote:> Dear all, > I would like to import a range of cells (e.g. F10:K234) from an Excel > worksheet to R. I have looked for documentation on RODBC and > RDCOMClient but I was not able to find enough information to solve my > problem and all the examples I have seen were dealing with an entire > worksheet, not a range of cells. Thanks, > > Jean-Noel > > Jean-Noel Candau > INRA - Unit? de Recherches Foresti?res M?diterran?ennes > Avenue A. Vivaldi > 84000 AVIGNON > Tel: (33) 4 90 13 59 22 > Fax: (33) 4 90 13 59 59 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
Jean-Noel wrote:> Dear all, > I would like to import a range of cells (e.g. F10:K234) from an Excel > worksheet to R. I have looked for documentation on RODBC and RDCOMClient but > I was not able to find enough information to solve my problem and all the > examples I have seen were dealing with an entire worksheet, not a range of > cells.In the case of RDCOMClient, you can do: xls <- COMCreate("Excel.Application") xls[["Workbooks"]]$Open("Book1.xls") rng <- xls[["ActiveSheet"]]$Range("F10:K234") x <- rng[["Value"]] Depending on what the range contains (e.g., the range consists of only one data type or not), x may be a list with each element corresponding to a column in the excel range. The thing to remember here is how to build ranges -- e.g., use the Range() method of the worksheet. This, though, is not R specific, and it's determined by the Excel COM specification. Regards, -- David> Thanks, > > Jean-Noel > > Jean-Noel Candau > INRA - Unit? de Recherches Foresti?res M?diterran?ennes > Avenue A. Vivaldi > 84000 AVIGNON > Tel: (33) 4 90 13 59 22 > Fax: (33) 4 90 13 59 59 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html