Replace all NA with FALSE in selected columns in R

前端 未结 5 1826
挽巷
挽巷 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:28

    You can use the NAToUnknown function in the gdata package

    df[,c('x1', 'x2')] = gdata::NAToUnknown(df[,c('x1', 'x2')], unknown = 'FALSE')
    

提交回复
热议问题