Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. other_replace <- function(df,column_name,other_month,other_ei,wrong)
  2. {
  3. require("dplyr")
  4.  
  5. other_month <- as.name(other_month)
  6. other_ei <- as.name(other_ei)
  7.  
  8.  
  9. equipt <- c("ov_ap","rub_bo","wrk_bo","mask","gog","glov","non")
  10. for(i in equipt){
  11.  
  12. column_name<- as.name(paste(c(column_name,i),sep="_"))
  13.  
  14. column_name2 <- as.name(paste("p17a.1.gear_othcon",i,sep="_"))
  15.  
  16.  
  17. df <- df %>% mutate(column_name=ifelse(other_month==wrong|
  18. other_ei==wrong,
  19. replace(column_name,column_name2=="1","1"),
  20. column_name))
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement