r change yes no to 0 1 code example Example: r change yes no to 0 1 df$myvar <- ifelse(df$myvar=="Yes", 0, 1)