Learn R Programming

wrMisc (version 1.2.3)

readXlsxBatch: Read batch of Excel xlsx-files

Description

readXlsxBatch reads data out of multiple xlsx files, the sheet indicated by 'sheetInd' will be considered. All files must have a very similar organization of data, as this is typically the case when high-throughput measurments are automatically saved while the screen progresses. The file-names will be used to structure the data read. By default all columns with text-content may be eliminated to extract the numeric part only, which may then get organized to a 3-dim array. NOTE : requires package xlsx being installed ! Uses a considerable amount of RAM ! Reading multiple xlsx files does take some time.

Usage

readXlsxBatch(
  fileNames = NULL,
  path = ".",
  fileExtension = "xlsx",
  excludeFiles = NULL,
  sheetInd = 1,
  checkFormat = TRUE,
  returnArray = TRUE,
  columns = c("Plate", "Well", "StainA"),
  simpleNames = 3,
  silent = FALSE,
  callFrom = NULL
)

Arguments

fileNames

(character) provide either explicit list of file-names to be read or leave NULL for reading all files ending with 'xlsx' in path specified with argument path

path

(character) there may be a different path for each file

fileExtension

(character) extension of files (default='xlsx')

excludeFiles

(character) names of files to exclude (only used when reading all files of given directory)

sheetInd

(integer) specify which sheet to extract (must be number, eg sheetInd=2 will extract always the 2nd sheet (no matter the name)

checkFormat

(logical) if TRUE: check header, remove empty columns, if rownames are increasing integeres it will searh for fisrt column with different entries to use as rownames

returnArray

(logical) allows switching from array to list-output

columns

(NULL or character) column-headers to be extracted (if specified, otherwise all columns will be extracted)

simpleNames

(integer), if NULL all characters of fileNames will be maintained, otherwise allows truncating names (from beginning) to get to variable part (using .trimFromStart()), but keeping at least the number of charcters indicated by this argument

silent

(logical) suppress messages

callFrom

(character) allows easier tracking of message(s) produced

Value

list

See Also

read.xlsx, for simple reading of xls-files under 32-bit R see also package RODBC

Examples

Run this code
# NOT RUN {
path1 <- system.file("extdata",package="wrMisc")
fiNa <- c("pl01_1.xlsx","pl01_2.xlsx","pl02_1.xlsx","pl02_2.xlsx")
datAll <- readXlsxBatch(fiNa,path1)
str(datAll)
datAll2 <- readXlsxBatch(path=path1,silent=TRUE)
identical(datAll,datAll2)
# }

Run the code above in your browser using DataLab