Learn R Programming

XLConnect (version 0.2-3)

setMissingValue-methods: Setting missing value identifiers

Description

Defines the set of missing value strings used when reading and writing data.

Usage

## S3 method for class 'workbook,ANY':
setMissingValue(object,value)

Arguments

object
The workbook to use
value
character vector of missing value identifiers that are recognized as missing (NA) when reading data. The first element of this vector will be used as missing value identifier when writing data. If value = NULL

Details

If there are no specific missing value identifiers defined the default behavior is to map missing values to blank (empty) cells. Otherwise, each string cell is checked if it matches one of the defined missing value identifiers. In addition, the first missing value identifier (i.e. the first element of the value argument) is used to represent missing values when writing data. Note that the missing value mapping only works with string identifiers. If you want to use e.g. numeric missing value identifiers such as e.g. -9999 then you have to perform the mapping manually (i.e. replace items with NA before writing / replace items with NA after reading).

See Also

workbook, writeNamedRegion, writeWorksheet

Examples

Run this code
# Load workbook (create if not existing)
wb <- loadWorkbook("missingValue.xlsx", create = TRUE)

# Create a worksheet named 'airquality'
createSheet(wb, name = "airquality")

# Create a named region called 'airquality' on the sheet called
# 'airquality'
createName(wb, name = "airquality", formula = "airquality!$A$1")

# Set the missing value string to 'missing'
setMissingValue(wb, value = "missing")

# Write built-in data set 'airquality' to the above defined named region
writeNamedRegion(wb, airquality, name = "airquality")

# Save workbook
saveWorkbook(wb)

Run the code above in your browser using DataLab