Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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")
- ## get all possible names associated with each brand
- nms <- tackref[tackref$tack_brand %in% bb,]$tack_name
- ## for bb = "Bard Davol", nms will
- ##[1] "Bard Davol CapSure" "Bard Davol OptiFix" "Bard Davol Permafix"
- ## [4] "Bard Davol Permasorb" "Bard Davol Sorbafix"
- ## get variable names associated with brand bb
- vnms <- lapply(nms, FUN = function(x) var %|% "_" %|% gsub(" ", "_", tolower(x)) %|% "_ref") %>% unlist
- ## for bb = "Bard Davol", vnms will be
- [1] "inguinal_mesh_left_tack_name_bard_davol_capsure_ref"
- [2] "inguinal_mesh_left_tack_name_bard_davol_optifix_ref"
- [3] "inguinal_mesh_left_tack_name_bard_davol_permafix_ref"
- [4] "inguinal_mesh_left_tack_name_bard_davol_permasorb_ref"
- [5] "inguinal_mesh_left_tack_name_bard_davol_sorbafix_ref"
- ## so now I need to create a variable that does:
- ## if inguinal_mesh_left_tack_name_bard_davol_capsure_ref == "Yes" | "inguinal_mesh_left_tack_name_bard_davol_optifix_ref" == "Yes" |
- ... | "inguinal_mesh_left_tack_name_bard_davol_sorbafix_ref" == "Yes" then "Yes" otherwise "No"
- ## 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
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement