read.xls {xlsReadWrite} | R Documentation |
Reads an Excelsheet and returns a data.frame or a matrix. Supported is the native BIFF8 file format, i.e. Excel 97-2003.
read.xls( file, colNames = TRUE, sheet = 1, type = "data.frame", from = 1, rowNames = NA, colClasses = NA, checkNames = TRUE, dateTimeAs = "numeric", stringsAsFactors = default.stringsAsFactors() )
file |
the name of a file. If it does not contain an absolute path, the file name is relative to the current working directory. |
colNames |
a character vector or a logical. TRUE takes a title row
from the spreadsheet. The default is "V" followed by the column number. |
sheet |
to read from. A case sensitive character string or a number. |
type |
the type of the returned value. Either data.frame or -
for matrices - double , integer , logical or character . |
from |
the starting row to read from. |
rowNames |
a character vector with the actual row names or TRUE to
use the first Excel column.
With NA the first column will be considered to contain row names
under two conditions: 1) colNames is TRUE or contains a character
vector and 2) the first column name thereof is an empty string. |
colClasses |
the class of the data.frame columns. Possible entries are:
double , numeric , integer , logical , character ,
factor , NA , isodate , isotime and isodatetime .
A scalar entry will be recycled if necessary.
isodate retrieves a "YYYY-MM-DD", isotime a "hh:mm:ss" and
isodatetime a "YYYY-MM-DD hh:mm:ss" character string.
With NA a suitable column type will be determined based on the
first non-empty entry of the first 16 rows of the Excelsheet. |
checkNames |
with TRUE the colNames are guaranteed to be
syntactically valid variable names (by make.names ). |
dateTimeAs |
controls how to determine a column class for columns which are
formatted as date, time or datetime. Possible entries are: numeric
or isodatetime . Will be overruled by explicit colClasses arguments. |
stringsAsFactors |
set to FALSE to retrieve plain characters. The
default follows the global option default.stringsAsFactors() . |
The arguments colNames
and/or colClasses
can optionally include
an entry for the rownames column (which will be discarded).
A data.frame or a matrix of the specified type.
While the free version should be sufficient for most day-to-day duties, you have
the opportunity to choose a more powerful pro version and at the same time support
our development and maintenance effort. Additional features of xlsReadWritePro:
- work with data area subsets, - use (named) ranges and pick individual cells,
- work with sheets (copy, rename, delete), - read/write formula values,
- insert images, - use oleDateTime classes and many datetime helper functions,
- append data to existing files and - work with in-memory objects (e.g. to compose Excel reports).
The trial (http://treetron.googlepages.com) is free and the two versions can easily be switched and coexist just fine. So, why not check it out for yourself?
Hans-Peter Suter
write.xls
,
read.table
, matrix
, data.frame