0

currently, I am cleaning my dataset (Comparative Manifesto Project) and try to compute the effective number of parties using the enp function from the electoral package (https://www.rdocumentation.org/packages/electoral/versions/0.1.2/topics/enp). However, I am running in some issues.

When I run this code:

cmp_1990 %>% 
  mutate(enp_vote = round(pervote, digits = 2)) %>%
  mutate(enp_vote = as.numeric(enp_vote)) %>%
  relocate(enp_vote, .before = parfam) %>% 
  mutate(enp_vote = enp(votes = cmp_1990$enp_vote)) %>%
  relocate(enp, .before = parfam)

I get the error message:

Fehler: Can't subset columns that don't exist.
x Column `enp` doesn't exist.

I suppose, r thinks of the function enp as single column even though I have installed and used library on the package.

I tried it with differently rounded numbers and by using the enp command outside of the rest of the command but up until now nothing worked. Oh and the cmp_1990$enp_vote command was necessary as otherwise the enp function thought of enp_vote as categorical and not numerical value.

Sorry by the way if my code doesnt look like the nicest, its my first time using r haha.

Thanks very much in advance!

  • Could you please provide some information about the "cmp_1990" data so that your problem could be reproduced? If you need guidance on doing this, see: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610 – Emmanuel Apr 15 '22 at 10:44

0 Answers0