[R-br] Erro: estouro da pilha de contexto (O que fazer?)

Rodrigo Coster rcoster em gmail.com
Sábado Abril 26 12:03:31 BRT 2014


Tenta usar o %in% para reduzir os ifelse() (Não sei se é o caso, mas a
função SE() do excel tem limite encadeiamentos, pode ser o caso aqui
também)... Ex:

Todos esses ifelse()'s:

ifelse((origin=="am") & (destination=="ro"),1,ifelse((origin=="am") &
(destination=="rr"),1,ifelse((origin=="am") &
(destination=="pa"),1,ifelse((origin=="am")
& (destination=="mt"),1

Podem ser substituido por:

ifelse(origin=="am" & destination %in% c("ro", "rr", "pa", "mt"),1,
ifelse(...))

E ainda assim acho que não é o mais adequado... Dependendo de como estão os
teus dados, eu usaria um merge() para resolver o problema


[]'s


2014-04-25 20:17 GMT-03:00 Alexandre Loures <alexandre.loures em ymail.com>:

>  Boa noite!
>
>
> Estou usando a rotina abaixo para construir uma dummy para as fronteiras
> dos estados brasileiros. Porém, quando tendo rodar o R reporta o seguinte
> erro:
>
> Erro: estouro da pilha de contexto na linha 18
>
>
> O que devo fazer?
>
>
> mydata$contiguity<-ifelse((origin=="ac") & (destination=="am"),1,
> ifelse((origin=="am") & (destination=="ro"),1,ifelse((origin=="am") &
> (destination=="rr"),1,ifelse((origin=="am") &
> (destination=="pa"),1,ifelse((origin=="am") & (destination=="mt"),1,
> ifelse((origin=="ro") & (destination=="mt"),1,ifelse((origin=="ro") &
> (destination=="am"),1,
> ifelse((origin=="rr") & (destination=="am"),1,ifelse((origin=="rr") &
> (destination=="pa"),1,
> ifelse((origin=="pa") & (destination=="mt"),1,ifelse((origin=="pa") &
> (destination=="am"),1,ifelse((origin=="pa") &
> (destination=="am"),1,ifelse((origin=="pa") & (destination=="rr"),1,
> ifelse((origin=="pa") & (destination=="ap"),1,ifelse((origin=="pa") &
> (destination=="ma"),1,ifelse((origin=="pa") &
> (destination=="to"),1,ifelse((origin=="pa") & (destination=="mt"),1,
> ifelse((origin=="ap") & (destination=="pa"),1,
> ifelse((origin=="ma") & (destination=="pa"),1,ifelse((origin=="ma") &
> (destination=="to"),1,ifelse((origin=="ma") & (destination=="pi"),1,
> ifelse((origin=="pi") & (destination=="ma"),1,ifelse((origin=="pi") &
> (destination=="to"),1,ifelse((origin=="pi") &
> (destination=="pe"),1,ifelse((origin=="pi") & (destination=="ce"),1,
> ifelse((origin=="ce") & (destination=="pi"),1,ifelse((origin=="ce") &
> (destination=="pe"),1,ifelse((origin=="ce") &
> (destination=="pb"),1,ifelse((origin=="ce") & (destination=="rn"),1,
> ifelse((origin=="rn") & (destination=="ce"),1,ifelse((origin=="rn") &
> (destination=="pb"),1,
> ifelse((origin=="pb") & (destination=="rn"),1,ifelse((origin=="pb") &
> (destination=="ce"),1,ifelse((origin=="pb") & (destination=="pe"),1,
> ifelse((origin=="pe") & (destination=="pb"),1,ifelse((origin=="pe") &
> (destination=="ce"),1,ifelse((origin=="pe") &
> (destination=="pi"),1,ifelse((origin=="pe") & (destination=="ba"),1,
> ifelse((origin=="pe") & (destination=="al"),1,
> ifelse((origin=="al") & (destination=="pe"),1,ifelse((origin=="al") &
> (destination=="ba"),1,ifelse((origin=="al") & (destination=="se"),1,
> ifelse((origin=="se") & (destination=="al"),1,ifelse((origin=="se") &
> (destination=="ba"),1,
> ifelse((origin=="ba") & (destination=="se"),1,ifelse((origin=="ba") &
> (destination=="al"),1,ifelse((origin=="ba") &
> (destination=="pe"),1,ifelse((origin=="ba") & (destination=="pi"),1,
> ifelse((origin=="ba") & (destination=="to"),1,ifelse((origin=="ba") &
> (destination=="go"),1,ifelse((origin=="ba") &
> (destination=="mg"),1,ifelse((origin=="ba") & (destination=="es"),1,
> ifelse((origin=="to") & (destination=="pa"),1,ifelse((origin=="to") &
> (destination=="mt"),1,ifelse((origin=="to") &
> (destination=="go"),1,ifelse((origin=="to") & (destination=="ba"),1,
> ifelse((origin=="to") & (destination=="pi"),1,ifelse((origin=="to") &
> (destination=="ma"),1,
> ifelse((origin=="mt") & (destination=="ro"),1,ifelse((origin=="mt") &
> (destination=="am"),1,ifelse((origin=="mt") &
> (destination=="pa"),1,ifelse((origin=="mt") & (destination=="to"),1,
> ifelse((origin=="mt") & (destination=="go"),1,ifelse((origin=="mt") &
> (destination=="ms"),1,
> ifelse((origin=="ms") & (destination=="mt"),1,ifelse((origin=="ms") &
> (destination=="go"),1,ifelse((origin=="ms") &
> (destination=="mg"),1,ifelse((origin=="ms") & (destination=="sp"),1,
> ifelse((origin=="ms") & (destination=="pr"),1,
> ifelse((origin=="go") & (destination=="mg"),1,ifelse((origin=="go") &
> (destination=="ba"),1,ifelse((origin=="go") &
> (destination=="to"),1,ifelse((origin=="go") & (destination=="mt"),1,
> ifelse((origin=="go") & (destination=="ms"),1,ifelse((origin=="go") &
> (destination=="df"),1,
> ifelse((origin=="mg") & (destination=="sp"),1,ifelse((origin=="mg") &
> (destination=="rj"),1,ifelse((origin=="mg") &
> (destination=="es"),1,ifelse((origin=="mg") & (destination=="ba"),1,
> ifelse((origin=="mg") & (destination=="go"),1,ifelse((origin=="mg") &
> (destination=="ms"),1,
> ifelse((origin=="sp") & (destination=="rj"),1,ifelse((origin=="sp") &
> (destination=="mg"),1,ifelse((origin=="sp") &
> (destination=="ms"),1,ifelse((origin=="sp") & (destination=="pr"),1,
> ifelse((origin=="rj") & (destination=="mg"),1,ifelse((origin=="rj") &
> (destination=="mg"),1,ifelse((origin=="rj") & (destination=="es"),1,
> ifelse((origin=="es") & (destination=="ba"),1,ifelse((origin=="es") &
> (destination=="mg"),1,ifelse((origin=="es") & (destination=="rj"),1,
> ifelse((origin=="pr") & (destination=="sp"),1,ifelse((origin=="pr") &
> (destintaion=="sc"),1,ifelse((origin=="pr") & (destination=="ms"),1,
> ifelse((origin=="sc") & (destination=="pr"),1,ifelse((origin=="sc") &
> (destination=="rs"),1,
> ifelse((origin=="rs") & (destination=="sc"),1,
> ifelse((origin=="df") &
> (destination=="go"),1,0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
>
>
>
> --
> *Alexandre Rodrigues Loures*
>
> _______________________________________________
> R-br mailing list
> R-br em listas.c3sl.ufpr.br
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça
> código mínimo reproduzível.
>
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://listas.inf.ufpr.br/pipermail/r-br/attachments/20140426/f36441ec/attachment.html>


Mais detalhes sobre a lista de discussão R-br