daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Feb 17th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'data.frame':   41953 obs. of  5 variables:
  2.  $ trust_gov       : Factor w/ 6 levels "A lot","Somewhat",..: 1 2 2 2 1 2 4 2 2 2 ...
  3.  $ medwell_accuracy: Factor w/ 7 levels "Very well","Somewhat well",..: 2 4 2 3 4 2 1 1 1 1 ...
  4.  $ medwell_leaders : Factor w/ 7 levels "Very well","Somewhat well",..: 2 3 2 4 4 3 1 2 1 1 ...
  5.  $ medwell_unbiased: Factor w/ 7 levels "Very well","Somewhat well",..: 4 4 2 4 3 2 1 2 1 3 ...
  6.  $ medwell_coverage: Factor w/ 7 levels "Very well","Somewhat well",..: 2 4 1 3 3 2 1 1 2 3 ...
  7.  - attr(*, "variable.labels")= Named chr  "ID. Respondent ID" "Survey" "Country" "QSPLIT. Split form A or B" ...
  8.   ..- attr(*, "names")= chr  "ID" "survey" "Country" "qsplit" ...
  9.  - attr(*, "codepage")= int 65001
  10.    
  11. nm <- grep("medwell_", names(df))
  12. num <- colSums(apply(df[, nm], 1, `%in%`, c("Very well", "Somewhat well")))
  13. df$new <- ifelse(num == 3, "SAT", "NON_SAT")
  14.    
  15. df %>%
  16.   mutate(
  17.     new = ifelse(
  18.       select(., contains("medwell_")) %>%
  19.         map2_dfr(list(c("Very well", "Somewhat well")), `%in%`) %>%
  20.         rowSums() == 3, "SAT", "NON_SAT"
  21.     )
  22.   )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top