Replace all NA with FALSE in selected columns in R

前端 未结 5 1814
挽巷
挽巷 2020-12-31 01:57

I have a question similar to this one, but my dataset is a bit bigger: 50 columns with 1 column as UID and other columns carrying either TRUE or NA

5条回答
  •  天命终不由人
    2020-12-31 02:37

    tidyr::replace_na excellent function.

    df %>%
      replace_na(list(x1 = FALSE, x2 = FALSE))
    

    This is such a great quick fix. the only trick is you make a list of the columns you want to change.

提交回复
热议问题