【发布时间】:2022-06-30 14:59:25
【问题描述】:
我有一个可以是NULL 或字符串的值。第二个测试失败,因为a 的长度为0。
我如何编写处理这两种情况的if-statement?
例子:
a <- NULL
if (is.null(a) | a=="something else then null") {
print("test")
}
【问题讨论】:
标签: r if-statement null
我有一个可以是NULL 或字符串的值。第二个测试失败,因为a 的长度为0。
我如何编写处理这两种情况的if-statement?
例子:
a <- NULL
if (is.null(a) | a=="something else then null") {
print("test")
}
【问题讨论】:
标签: r if-statement null
is.null(a) || a=="something else then null"
(类似地,在这种情况下使用&& 而不是&)
【讨论】:
or 是必要的吗?