Can someone please explain me what I am doing wrong. I don't understand the behaviour of the ifelse function in R. I expected that the ifelse function would return the whole list ids_match. However, these are the results I get with RStudio Version 1.3.1093 in the Console Window:
cond1 = FALSE
cond2 = FALSE
cond3 = TRUE
ids_match = list(1, 2, 3)
ifelse(cond1 & cond2 & cond3, ids_match[1], ids_match)
[[1]]
[1] 1
ifelse(TRUE, ids_match[1], ids_match)
[[1]]
[1] 1
ifelse(FALSE, ids_match[1], ids_match)
[[1]]
[1] 1
ifelse(FALSE, "TRUE", "FALSE")
[1] "FALSE"
ifelse(TRUE, "TRUE", "FALSE")
[1] "TRUE"`
question from:
https://stackoverflow.com/questions/65933469/struggling-with-the-ifelse-function-in-r 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…