readFromExcel: Read data into a variable from an Excel file

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

View source: R/readFromExcel.r

Description

Use this function to read data from an excel sheet into an R variable.

Usage

1
2
3
4
5
6
7
8
readFromExcel(file = choose.files(), sheet = 1,
  stringsAsFactors = default.stringsAsFactors(),
  simplify = TRUE, drop = TRUE, 
  na.strings = c("", "NA", "#DIV/0!"), 
  zero.strings = "-",  
  convertFormattedNumbers = TRUE, ..., 
  header = TRUE, rowheader = FALSE,
  pkg = c("XLConnect", "RODBC", "xlsx"))

Arguments

file

file to read from; if not specified (missing) you will be asked to browse to the file to "Open"

sheet

sheet name or number to read from

stringsAsFactors

keep default

simplify

should matrices with length 1 in one of the dimensions be converted to vectors (TRUE)?

drop

if TRUE and one of the dimensions of the matrix has length 1, return a vector

na.strings

strings that you want considered to be NA

zero.strings

strings that you want considered to be zero

convertFormattedNumbers

do you want to eliminate dollar signs, commas, etc. in formatted numbers (TRUE) or read those cells as character values (FALSE)?

header

did you copy the column header(s) too?

rowheader

did you copy the row header(s)/name(s) too?

pkg

name of the package to use to read the actual cells. Choices are currently "XLConnect", "RODBC", "xlsx".

...

arguments to be passed to other methods

Details

Essentially a wrapper for other R packages that standardizes the argument list throughout the excelRio package.

Value

An R object, either a data.frame, a matrix or a vector.

Author(s)

dmm

See Also

writeToCsv, readFromCsv, pasteFromExcel, copyToExcel

Examples

1
2
3
4
5
6
# In Excel, save a sheet of data to a csv file, e.g., Book1.csv. 
# Suppose the data was a table of data by accident year,
# with the accident years being in column A, thereby "naming" the rows of data.
# Back in R ...
### NOT RUN
# x <- readFromExcel("Book1.xlsx", rowheader = TRUE)

trinostics/excelRio documentation built on June 18, 2020, 4:41 p.m.