Why do the if-else construct and the function ifelse() behave differently?
mylist <- list(list(a=1, b=2), list(x=10, y=20)) l1 <- ifelse(sum(sapply(my
For some reason this is marked as a duplicate of Why does ifelse() return single-value output?
So a work around for that question is:
a=3 yo <- ifelse(a==1, 1, list(c(1,2))) yo[[1]]