You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used recode() to both recode and add value labels at the same time. I realized some value labels were missing in certain variables.
Below is an example. The responses are 1, 4, 5, 6, 7. I want to recode them 1 to 5, 4 to 4, 5 to 3, 6 to 2, and 7 to 1 with value labels 5 = Always, 4 = Often, and so on.
The following result of val_lab() shows that 1 = Never is missing in Q2 and Q3 even when Q2 does have values of 1. And Q7, with only the values of 5 and NA, is applied with the correct value labels.
If I used a different approach: Using recode() to first recode the values, then num_lab() and val_lab() to assign the value labels, everything worked as planned.
df3<-expss::recode(df1[1:length(df1)], 1~5, 4~4, 5~3, 6~2, 7~1, T~copy)
val_lab(df3) <- num_lab("1 Never 2 Rarely 3 Sometimes 4 Often 5 Always")
I used
recode()
to both recode and add value labels at the same time. I realized some value labels were missing in certain variables.Below is an example. The responses are 1, 4, 5, 6, 7. I want to recode them 1 to 5, 4 to 4, 5 to 3, 6 to 2, and 7 to 1 with value labels 5 = Always, 4 = Often, and so on.
The following result of
val_lab()
shows that 1 = Never is missing in Q2 and Q3 even when Q2 does have values of 1. And Q7, with only the values of 5 and NA, is applied with the correct value labels.If I used a different approach: Using
recode()
to first recode the values, thennum_lab()
andval_lab()
to assign the value labels, everything worked as planned.The result is
As I haven't seen anyone posted this issue on github or stackoverflow, I am assuming I must have missed something. Please help. Thanks!
The text was updated successfully, but these errors were encountered: