R语言assertthat包 assert |
您所在的位置:网站首页 › groupcounts › R语言assertthat包 assert |
返回R语言assertthat包函数列表 功能\作用概述:ighd_hum_df是stopifnot的一个插入式替代品,但它的设计目的是提供信息性的错误消息。 语法\用法:assert_that(..., env = parent.frame(), msg = NULL) see_if(..., env = parent.frame(), msg = NULL) 参数说明:... : 未命名的表达式,用于描述要创建的条件测试过了而不是将表达式与&&,用commasso将它们分开,这样可以生成更好的错误消息。 env : (仅限高级用途)评估评估的环境。 msg : 如果其中一个条件为false,则打印自定义错误消息。 示例\实例:x < - 1# assert_that() generates errors, so can't be usefully run in# examples## Not run: assert_that(is.character(x))assert_that(length(x) == 3)assert_that(is.dir("asdf"))y < - tempfile()writeLines("", y)assert_that(is.dir(y))assert_that(FALSE, msg = "Custom error message") ## End(Not run) # But see_if just returns the values, so you'll see that a lot# in the examples: but remember to use assert_that in your code.see_if(is.character(x))see_if(length(x) == 3)see_if(is.dir(17))see_if(is.dir("asdf"))see_if(5 < 3, msg = "Five is not smaller than three") |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |