我对R比较陌生,请见谅。我有一个循环,其中有一个条件,用于比较两个列表并返回一个由TRUE / FALSE值组成的向量。我真正需要检查的是这个向量是否仅包含TRUE值(意味着两个列表相同)
for ( i in 1:(length(sessions_items_list)-1)){
if (sessions_items_list[[i]]==sessions_items_list[[i+1]]){
identical_sessions_df [i,1] <- names(sessions_items_list[i])
identical_sessions_df [i,2] <- names(sessions_items_list[i+1])
#identical_sessions_df [i,3] <- sessions_items_list[[i]]
#identical_sessions_df [i,4] <- sessions_items_list[[i+1]]
}
}
这里有一些数据:
> sessions_items_list[[2]]
[1] "111502665618" "111505397996" "121238758674" "121480200508" "131159477858" "161469302097" "161474935929" "171526802604" "231197187139" "231381216285" "251502101205" "261650031415"
[13] "261652085962" "261652452940" "271538491767" "281398254987" "291227243345" "311065441334" "321561638226" "321566237993" "331042848072" "331251405185" "331366646532" "361096154736"
[25] "381043841996"
> sessions_items_list[[3]]
[1] "111502665618" "111505397996" "121238758674" "131159477858" "161469302097" "161474935929" "171526802604" "231197187139" "231381216285" "251502101205" "261647474153" "261650031415"
[13] "261652085962" "261652452940" "271538491767" "281398254987" "291227243345" "311065441334" "321561638226" "321566237993" "331042848072" "331251405185" "331366646532" "361096154736"
[25] "381043841996"
以下是条件结果示例:
> sessions_items_list[[2]]==sessions_items_list[[3]]
[1] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
有没有一个简单的函数来检查这个谓词列表是否为真(所有值都为真)?