1

I have this table and i want to recode it:

table(d$votept)

  2   3   5   7   8  10  11  13  14  15  16  17  18 
 59  30   2   1   4   1   1 246   1   8 224  21   1 

But when i recode it with plyr::mapvalues like this:

d$votept<-plyr::mapvalues(d$votept, from = c(2,3,13,15,16,5,7,8,10,11,14,17,18),
                          to=c("Gauche","Gauche","Gauche","Gauche","Centre-droite",NA,NA,NA,NA,NA,NA,NA,NA))

i receive this message error:

Erreur : Can't convert character to double.

What Do I have to do, because 2 days before, this code worked?

Edgar16
  • 11
  • 1
  • 3
  • 1
    Very difficult to answer this without the proper data. My guess: d$votept is of class `charachter`. Try: `d$votept <- as.numeric(d$votept)` before you call `plyr::...` – MKR Apr 12 '21 at 15:06

0 Answers0