Package bRasilLegis [command "getDetailsDownload"]

4

I need to collect the data of the deputies who were present in commissions, positions, etc. However, I can only do this with one deputy at a time. Is it possible that I can choose all at once?

library(bRasilLegis)
dep <- obterDetalhesDeputado(ideCadastro = '81366' , numLegislatura = "55", 
atuacao = "comissoes")

The argument ideCadastro is where I should put the deputy code (in the above case it is '81366'), which is obtained by means of the code deputados <- obterDeputados() .

Is it possible to put all the codes at once?

    
asked by anonymous 02.01.2017 / 23:42

1 answer

4

The first thing to do is to get the list of deputies, as you put it well in the original post:

library(bRasilLegis)

deputados <- obterDeputados()

After that, it's interesting to see what's inside the deputados object. We do this through the str command. I'm not going to put all his output here, because it's a bit extensive. I'm just going to stick to the first column of the object deputados :

str(deputados)
'data.frame':   511 obs. of  16 variables:
 $ ideCadastro    : chr  "81366" "141522" "195826" "196358" ...

Even because it is what interests us, since the ids of the deputies are there. What we need to do now is a loop that changes the delegate id within each call of the obterDetalhesDeputado function. Just make a counter j assume all values of deputados$ideCadastro .

We also need to save these results in one place. I chose to save to a list, called dep .

Finally, the position within each element of the list should vary when the ids of the deputies vary. For this I created a second counter called i , which I will update manually after downloading the information of each deputy.

The complete code looks like this:

dep <- list()

i <- 1
for (j in deputados$ideCadastro){
    dep[[i]] <- obterDetalhesDeputado(ideCadastro=j, 
    numLegislatura="55", atuacao="comissoes")
    i <- i+1
}
    
03.01.2017 / 00:30