Md Shariful Islam
Md Shariful Islam

Reputation: 71

Recoding one hevan_labelled variable

I tried to recode one variable of a dataset of a complex survey. I have tried dplyr::recode function.

occup<-recode(sv$v717, c(0 )='0'; c(1, 2, 3 )='1'; c(4 )='2'; c(8, 9 )='3'; c(96, 98)='98'")

Earlier I did same way successfully. However, this time I am getting error like following

Error in UseMethod("recode") : no applicable method for 'recode' applied to an object of class "c('haven_labelled', 'vctrs_vctr', 'double')"

How can I fix this error or how can I recode a variable?

Upvotes: 2

Views: 1590

Answers (1)

Md Shariful Islam
Md Shariful Islam

Reputation: 71

I found the solution

occu<-car::recode(sv$v717, "c(0 )=0; c(1, 2, 3 )=1; c(4 )=2; c(8, 9 )=3; c(96, 98)=98")

recode function of Car package can solve this issue.

Upvotes: 1

Related Questions