R noob here..
I have the following data frame
>data
Value Multiplier
1 15 H
2 0 h
3 2 +
4 2 ?
5 2 k
where the multiplier is of class factor
. The values of K
& k
is 3
, +
is 5
and ?
is 2
.
I have used
> data$Multiplier <- revalue(data$Multiplier, c("+"="5"))
> data$Multiplier <- revalue(data$Multiplier, c("?"="2"))
> data$Multiplier <- revalue(data$Multiplier, c("K"="3"))
> data$Multiplier <- revalue(data$Multiplier, c("k"="3"))
Is there a better way of doing it?