Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. for(bb in unique(tackref$tack_brand)){ ## for bb in list of tack brands (bb will have values: "Bard Davol" "Medtronic" "Ethicon" "THD" "Via Surgical")
  2.  
  3. ## get all possible names associated with each brand
  4. nms <- tackref[tackref$tack_brand %in% bb,]$tack_name
  5. ## for bb = "Bard Davol", nms will
  6. ##[1] "Bard Davol CapSure" "Bard Davol OptiFix" "Bard Davol Permafix"
  7. ## [4] "Bard Davol Permasorb" "Bard Davol Sorbafix"
  8.  
  9. ## get variable names associated with brand bb
  10. vnms <- lapply(nms, FUN = function(x) var %|% "_" %|% gsub(" ", "_", tolower(x)) %|% "_ref") %>% unlist
  11. ## for bb = "Bard Davol", vnms will be
  12. [1] "inguinal_mesh_left_tack_name_bard_davol_capsure_ref"
  13. [2] "inguinal_mesh_left_tack_name_bard_davol_optifix_ref"
  14. [3] "inguinal_mesh_left_tack_name_bard_davol_permafix_ref"
  15. [4] "inguinal_mesh_left_tack_name_bard_davol_permasorb_ref"
  16. [5] "inguinal_mesh_left_tack_name_bard_davol_sorbafix_ref"
  17.  
  18. ## so now I need to create a variable that does:
  19. ## if inguinal_mesh_left_tack_name_bard_davol_capsure_ref == "Yes" | "inguinal_mesh_left_tack_name_bard_davol_optifix_ref" == "Yes" |
  20. ... | "inguinal_mesh_left_tack_name_bard_davol_sorbafix_ref" == "Yes" then "Yes" otherwise "No"
  21. ## but in the next loop iteration, bb will be "Medtronic" and different values for nms and vnams will occur, so I can't hardcode the above condition
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement