How to create Abels in a binary vector without it becoming categorical?

Asked

Viewed 98 times

3

I have a binary variable in a dataframe, want to assign the label "no" for the value 0 and "yes" for the value 1 without the vector becoming categorical (if this occurs, I cannot use the function svymean() ).

Does anyone know if this is possible?

  • Why not use the svytable() and then the prop.table() to get the percentage?

  • @Rcoster, getting the percentage is not a problem, I was really curious if this way of using label was possible. Thank you.

1 answer

1


That is not possible.

What you can do is let the R turn into factor, and when you use the svymean do so:

x <- c("sim", "sim", "não", "não")
svymean(x = as.numeric(x == "sim"), design = ?)

See what to use as.numeric(x == "sim") releases a vector of zeros and a:

[1] 1 1 0 0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.