码(伪)
x = c('Gender','Employee Status')
y = c('Gender','Employee Status','Tenure')
if (!(x %in% y)){do this}
else(do this)
我知道if
没有矢量化,而ifelse却是ifelse给了我一些错误。我使用的功能。有没有办法让if
矢量化以接受上面的多个输入?这样做并且这是一系列步骤。
答案 0 :(得分:0)
您可以使用设置表示法来检查X
是否在Y
# Setup
x <- c('Gender','Employee Status')
y <- c('Gender','Employee Status','Tenure')
# Check X in Y
if (identical(setdiff(x, y), character(0))) {
print("All of X in Y")
} else {
print("Not all of X in Y")
}