with.workbook: Evaluate an R expression in a workbook environment

Description Usage Arguments Details Author(s) See Also Examples

View source: R/with.workbook.R

Description

Evaluate an R expression in an environment constructed from the named regions of an Excel workbook.

Usage

1
2
## S3 method for class 'workbook'
with(data, expr, ...)

Arguments

data

A workbook object, as returned by loadWorkbook.

expr

expression to evaluate

...

Additional arguments passed to readNamedRegion

Details

This method will read all named regions from the workbook when creating the environment. Names in the workbook will be processed through make.names to obtain the variable names.

Changes to the variables representing named regions will not affect the workbook contents and need to be saved explicitly using writeNamedRegion and saveWorkbook. If the workbook contains names that do not map to R identifiers,

Author(s)

Martin Studer
Mirai Solutions GmbH https://mirai-solutions.ch

See Also

getDefinedNames, readNamedRegion,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# multiregion xlsx file from demoFiles subfolder of package XLConnect
demoExcelFile <- system.file("demoFiles/multiregion.xlsx",
                             package = "XLConnect")

# load workbook
wb <- loadWorkbook(demoExcelFile)

# named regions: Calendar, IQ, Iris
print(getDefinedNames(wb))

# named regions as variables
with(wb, { 
  print(Calendar)
  summary(IQ)
  summary(Iris)
})

## End(Not run)

XLConnect documentation built on April 11, 2021, 9:06 a.m.