I made the following example code to give you an idea of my real dataset. I have 2 datasets, a factor variable List
and a logical variable ok
.
我做了下面的示例代码,让您了解我的真实数据集。我有两个数据集,一个因子变量列表和一个逻辑变量。
df1 <- c("a","b","c","d","e","f","g")
df2 <- c("a","d","e")
List <- factor(as.integer(df1 %in% df2))
ok <- c(TRUE,FALSE, FALSE,FALSE,TRUE,FALSE,TRUE)
The List
and the ok
variables has both a length of 7. I want to remove all the samples in List
with the condition TRUE
in ok
. For example: the first, fifth and seventh variables need to be removed in the List
variable.
列表和ok变量的长度都是7。我想把列表中的所有样本都去掉,条件在ok中为真。例如:第一个、第五个和第七个变量需要在列表变量中删除。
Can anyone help me with this?
有人能帮我一下吗?
Thanks
谢谢
2 个解决方案
#1
3
Easier than you think.
比你想象的容易。
List[!ok]
#2
0
Perhaps List[!ok]
? BTW, you don't need as.logical
as vector ok
will be saved internaly as logical
.
也许列表(!好)?顺便说一句,你不需要as。逻辑作为向量ok将作为逻辑保存在内部。
#1
3
Easier than you think.
比你想象的容易。
List[!ok]
#2
0
Perhaps List[!ok]
? BTW, you don't need as.logical
as vector ok
will be saved internaly as logical
.
也许列表(!好)?顺便说一句,你不需要as。逻辑作为向量ok将作为逻辑保存在内部。