Here is the concrete example:

> # multiregion xlsx file from demoFiles subfolder of package XLConnect
> demoExcelFile <- system.file("demoFiles/multiregion.xlsx",
+                              package = "XLConnect")
>
> # Load a single named region into a single data.frame.
> DF1 <- readNamedRegionFromFile(demoExcelFile, name="Iris")
>
>
> DF2 <- readWorksheetFromFile(demoExcelFile, sheet="SecondSheet",
+
 startCol=col2idx("B"),
+
 endCol=col2idx("F"),
+
 startRow=3,
+                                                header=TRUE)
> head(DF1)
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
1          5.1         3.5          1.4         0.2    setosa
2          4.9         3.0          1.4         0.2    setosa
3          4.7         3.2          1.3         0.2 barbarica
4          4.6         3.1          1.5         0.2    setosa
5          5.0         3.6          1.4         0.2    setosa
6          5.4         3.9          1.7         0.4    setosa
> head(DF2)
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
1          5.1         3.5          1.4         0.2    setosa
2          4.9         3.0          1.4         0.2    setosa
3          4.7         3.2          1.3         0.2 barbarica
4          4.6         3.1          1.5         0.2    setosa
5          5.0         3.6          1.4         0.2    setosa
6          5.4         3.9          1.7         0.4    setosa
> identical(DF1, DF2)
[1] TRUE


Andrija


On Tue, Apr 23, 2013 at 9:04 AM, andrija djurovic <djandr...@gmail.com>wrote:

> Hi Miao.
>
> 1.  "Calendar", "Iris", "IQ" are the named region in excel file  
> multiregion.xlsx
> (demoFiles/multiregion.xlsx). Open this file (demoFiles/multiregion.xlsx),
> go to Formulas tab and click Name manager to see reference regions.
>
> 2. Check following functions:
> ?readWorksheet   #arguments startCol, startRow, endCol, endRow
> ?idx2col
> ?col2idx
>
> Example:
> > col2idx("AK")
> [1] 37
> > idx2col(37)
> [1] "AK"
>
> Hope this helps.
>
> Andrija
>
>
> On Tue, Apr 23, 2013 at 8:49 AM, jpm miao <miao...@gmail.com> wrote:
>
>> Hi,
>>
>>    I have two questions on the function "readNamedRegionFromFile" in
>> XLConnect pacakge.
>>
>> 1.
>>
>>    In the documentation,
>>
>> # multiregion xlsx file from demoFiles subfolder of package XLConnect
>> demoExcelFile <- system.file("demoFiles/multiregion.xlsx",
>>                              package = "XLConnect")
>>
>> # Load a single named region into a single data.frame.
>> df <- readNamedRegionFromFile(demoExcelFile, name="Iris")
>>
>> # Load multiple regions at once - returns a (named) list
>> # of data.frames.
>> df <- readNamedRegionFromFile(demoExcelFile,
>>                               name=c("Calendar", "Iris", "IQ"))
>>
>>    What are the names "Calendar", "Iris", "IQ"? I just couldn't find them
>> from the file.
>>
>> 2. Since my xlsx file is big, I might want to read data like AK9:AK18, for
>> example. If my computation is right, AK is the 37th column. Then I need to
>> tell the computer to read the 37th column, row 9 to row 18. Can I ask the
>> function (any function in the package) to read the column by the header
>> name (say, the name saved in AK1) instead of "37th"?
>>
>>     Thanks,
>>
>> Miao
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to