-1
I’m making web Scrapping from a website. And for that I need to check if a data.frame
exists or not.
Besides not being working, I realize that I have different results only changing the position of the keys {}
Example 1:
if(exists(carteiras_i)==T) {
if (nrow(carteiras)==0){
carteiras <- carteiras_i
} else {
carteiras <- carteiras %>% rbind(carteiras_i); rm(carteiras_i)
}
} else (exists(carteiras_i)==F){
print("Faz nada")
}
#> Erro: '{' inesperado in:
#> " }
#> } else (exists(carteiras_i)==F){"
#> > print("Faz nada")
#> [1] "Faz nada"
#> > }
#> Erro: '}' inesperado in " }"
#> > }
#> Erro: '}' inesperado in "}"
Example 2
if(exists(carteiras_i)==T) {
if (nrow(carteiras)==0){
carteiras <- carteiras_i
} else {
carteiras <- carteiras %>% rbind(carteiras_i); rm(carteiras_i)
}
} else (exists(carteiras_i)==F){print("Faz nada")}
#> Erro: '{' inesperado in:
#> " }
#> } else (exists(carteiras_i)==F){"
#> > }
#> Erro: '}' inesperado in "}"
What am I missing? Why the difference just changing the key?
Try
else if (!exists(carteiras_i))
orelse if (isFALSE(exists(carteiras_i)))
. Do not compare a condition or function with a logical value withF/T
, the value of the condition or function is already logical.– Rui Barradas