I am running the following if
conditin in R without any problem:
nrow<-ifelse(S1_input, 1, ifelse(S2_input & nchar(bands)>40, 2, ifelse(S1_S2_input & nchar(bands)>40, 3, ifelse (S2_input && nchar(bands)<40, 4, 5))))
Where S1_input
, S2_input
, S1_S2_input
are logical variables (TRUE / FALSE) (only one can be TRUE
, the rest FALSE
) and bands
is just a string variable
I am trying to share my code using a Jupiter Notebook and the same line is giving an error but ONLY when S1_input
is FALSE
Error in S2_input & nchar(bands) > 40: operations are possible only for numeric, logical or complex types
Traceback:
1. ifelse(S1_input, 1, ifelse(S2_input & nchar(bands) > 40, 2, ifelse(S1_S2_input &
. nchar(bands) > 40, 3, ifelse(S2_input && nchar(bands) < 40,
. 4, 5))))
2. ifelse(S2_input & nchar(bands) > 40, 2, ifelse(S1_S2_input &
. nchar(bands) > 40, 3, ifelse(S2_input && nchar(bands) < 40,
. 4, 5)))
Aucun commentaire:
Enregistrer un commentaire