replace NA with 0 and all other values/text as 1

前端 未结 3 1199
误落风尘
误落风尘 2021-01-29 00:58
airquality

    Ozone Solar.R Wind Temp Month Day
1      41     190  7.4   67     5   1
2      36     118  8.0   72     5   2
3      12     149 12.6   74     5   3
4             


        
3条回答
  •  梦毁少年i
    2021-01-29 01:25

    Assuming your dataframe is called airquality

    airquality$Ozone <- ifelse(is.na(airquality$Ozone), 0, 1) 
    

提交回复
热议问题