readRows: Read a contiguous set of rows into an R matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/readRows.R

Description

Read a contiguous set of rows into an R character matrix. Uses the RInterface for speed.

Usage

1
readRows(sheet, startRow, endRow, startColumn, endColumn = NULL)

Arguments

sheet

a Worksheet object.

startRow

a numeric value for the starting row.

endRow

a numeric value for the ending row. If NULL it reads all the rows in the sheet.

startColumn

a numeric value for the starting column.

endColumn

a numeric value for the ending column. Empty cells will be returned as "".

Details

Use the readRows function when you want to read a row or a block block of data from an Excel worksheet. Internally, the loop over rows is done in R, and the loop over columns is done in Java, so this function achieves good performance when number of rows << number of columns.

In general, you should prefer the function readColumns over this one.

Value

A character matrix.

Author(s)

Adrian Dragulescu

See Also

read.xlsx2 for reading entire sheets. See also addDataFrame for writing a data.frame to a sheet.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 

  file <- system.file("tests", "test_import.xlsx", package = "xlsx")

  wb     <- loadWorkbook(file)
  sheets <- getSheets(wb)

  sheet <- sheets[["all"]]
  res <- readRows(sheet, startRow=3, endRow=7, startColumn=3, endColumn=10)




## End(Not run)

xlsx documentation built on Nov. 10, 2020, 3:52 p.m.