clearNamedRegion-methods

0th

Percentile

Clearing named regions in a workbook

Clears named regions in a '>workbook.

Keywords
methods, utilities
Usage
# S4 method for workbook,character
clearNamedRegion(object, name)
Arguments
object

The '>workbook to use

name

The name of the named region to clear

Details

Clearing a named region/range means to clear all the cells associated with that named region. Clearing named regions can be useful if (named) data sets in a worksheet need to be replaced, i.e. data is first read, modified in R and finally written back to the the same named region. Without clearing the named region first, (parts of) the original data may still be visible if they occupied a larger range in the worksheet.

See Also

'>workbook, clearSheet, clearRange, clearRangeFromReference, clearSheet

Aliases
  • clearNamedRegion
  • clearNamedRegion-methods
  • clearNamedRegion,workbook,character-method
Examples
# NOT RUN {
# mtcars xlsx file from demoFiles subfolder of 
# package XLConnect
demoExcelFile <- system.file("demoFiles/mtcars.xlsx", 
                             package = "XLConnect")

# Load workbook
wb <- loadWorkbook(demoExcelFile)

# Read named region 'mtcars'
data <- readNamedRegion(wb, name = "mtcars", header = TRUE)

# Only consider cars with a weight >= 5
data <- data[data$wt >= 5, ]

# Clear original named region
clearNamedRegion(wb, name = "mtcars")

# Write subsetted data back
# Note: this is covering a smaller area now -
# writeNamedRegion automatically redefines the named region
# to the size/area of the data
writeNamedRegion(wb, data = data, name = "mtcars",
                 header = TRUE) 
# }
Documentation reproduced from package XLConnect, version 0.2-14, License: GPL-3

Community examples

Looks like there are no examples yet.