Replace empty values with value from other column in a dataframe

后端 未结 3 1053
说谎
说谎 2020-11-30 11:57

In one column of my dataframe I have some empty cells. The data looks like this:

   yymmdd    lat   lon mag depth knmilocatie baglocatie   tijd
 19861226 52.         


        
3条回答
  •  借酒劲吻你
    2020-11-30 12:36

    You need to index also the replacing column:

    df[ df$baglocatie == "", "baglocatie"  ]  <- df[ df$baglocatie == "", "knmilocatie" ]
    

提交回复
热议问题