onErrorCell-methods(XLConnect)
onErrorCell-methods()所属R语言包:XLConnect
Behavior when error cells are detected
检测到错误信息时,单元的行为
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function defines the behavior when reading data from a worksheet and error cells are detected.
当检测到读取数据的工作表和错误单元格时,这个函数定义的行为。
用法----------Usage----------
## S4 method for signature 'workbook'
onErrorCell(object,behavior)
参数----------Arguments----------
参数:object
The workbook to use
workbook使用
参数:behavior
The behavior to follow when an error cell is detected. This is normally specified by a corresponding XLC error constant, i.e. either XLC$"ERROR.WARN" or XLC$"ERROR.STOP". XLC$"ERROR.WARN" means the error cell will be read as missing value (NA) and a corresponding warning will be generated (this is the default behavior). XLC$"ERROR.STOP" means that an exception will be thrown and further execution will be stopped immediately.
按照检测到错误时单元的行为。这通常是指定的对应的XLC错误不断的,即是XLC$"ERROR.WARN"或XLC$"ERROR.STOP"。 XLC$"ERROR.WARN"是指错误的单元格将被读为遗漏值(NA)会产生相应的警告(这是默认的行为)。 XLC$"ERROR.STOP"是指会抛出一个异常,进一步将立即停止执行。
(作者)----------Author(s)----------
Martin Studer<br>
Mirai Solutions GmbH <a href="http://www.mirai-solutions.com">http://www.mirai-solutions.com</a>
参见----------See Also----------
workbook, readNamedRegion, readNamedRegionFromFile, readWorksheet,<br> readWorksheetFromFile
workbook,readNamedRegion,readNamedRegionFromFile,readWorksheet,参考readWorksheetFromFile
实例----------Examples----------
# errorCell xlsx file from demoFiles subfolder of package XLConnect[errorCell xlsx文件demoFiles子文件夹中的包XLConnect]
demoExcelFile <- system.file("demoFiles/errorCell.xlsx",
package = "XLConnect")
# Load workbook[负载工作簿]
wb <- loadWorkbook(demoExcelFile)
# Set error behavior to XLC$ERROR.WARN when detecting error cells[当检测到错误单元格设置错误行为,XLC $ ERROR.WARN]
# Note: this is the default behavior[注:这是默认的行为]
onErrorCell(wb, XLC$ERROR.WARN)
# Alternatively: wb$onErrorCell(XLC$ERROR.WARN)[另一种方法:WB $ onErrorCell(XLC $ ERROR.WARN)]
# Read named region 'MyData' (with default header = TRUE)[阅读命名区域“MyData的”(默认的头= TRUE)]
data <- readNamedRegion(wb, name = "MyData")
# Now set error behavior to XLC$ERROR.STOP to immediately[现在XLC ERROR.STOP立即设置错误行为]
# issue an exception and stop in case an error cell is[发出异常并停止错误的情况下单元是]
# detected[检测]
onErrorCell(wb, XLC$ERROR.STOP)
# Alternatively: wb$onErrorCell(XLC$ERROR.STOP)[另一种方法:WB $ onErrorCell(XLC ERROR.STOP)]
# Read (again) named region 'MyData' (with default header = TRUE)[阅读()命名区域“MyData的”(默认的头= TRUE)]
res <- try(readNamedRegion(wb, name = "MyData"))
# Did we get an error?[我们得到一个错误?]
print(is(res, "try-error"))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|