adibender/coalitions

error in get_seats

adibender opened this issue · 2 comments

Forsa released 2 surveys in one day. Appears to cause errors

Unfortunately the error is still remaining using the updated devel branch:

> library(coalishin)
> crawl_data("btw", oldest_date = "2017-11-19")
> calc_coalProbs("btw", nsim = 2)
[1] "Perform new calculations for emnid..."
Fehler: Variable context not set

Diving deeper in...

... the error occurs when calling get_seats() with the following arguments:

> coalitions::get_seats(dirichlet.draws, survey = survey)
>
> dirichlet.draws
# A tibble: 2 x 7
        cdu       spd     greens        fdp       left        afd     others
      <dbl>     <dbl>      <dbl>      <dbl>      <dbl>      <dbl>      <dbl>
1 0.3422612 0.2201756 0.10020337 0.08320351 0.08887311 0.11357332 0.05170989
2 0.3476682 0.2107091 0.09788788 0.08979953 0.09942729 0.09914343 0.05536463
>
> survey
# A tibble: 7 x 7
        date      start        end respondents  party percent  votes
      <date>     <date>     <date>       <dbl>  <chr>   <dbl>  <dbl>
1 2017-11-25 2017-11-20 2017-11-23        1225    cdu      33 404.25
2 2017-11-25 2017-11-20 2017-11-23        1225    spd      22 269.50
3 2017-11-25 2017-11-20 2017-11-23        1225 greens      10 122.50
4 2017-11-25 2017-11-20 2017-11-23        1225    fdp       9 110.25
5 2017-11-25 2017-11-20 2017-11-23        1225   left      10 122.50
6 2017-11-25 2017-11-20 2017-11-23        1225    afd      11 134.75
7 2017-11-25 2017-11-20 2017-11-23        1225 others       5  61.25

Diving even deeper in...

... the error occurs when calling gather() inside get_seats().

sry, cannot reproduce. From the output it appears as if error occurs for "emnid" data.
Just ran the workflow vignette manually with dates going back before the election ... no errors.

Will need a pure coalitions reprex (no coalishin dependency)