Changing value of data frame based on another data frame

前端 未结 1 1238
清酒与你
清酒与你 2021-01-14 15:33

Again I need your help for a maybe easy question that is not clear for a starter R user.

I need to manipulate a dataframe to substitute NA values by \"

相关标签:
1条回答
  • 2021-01-14 15:53

    It's actually quite simple to do this without a for loop: if your data frames are A and B, then the command would be

    A[A == -3] = B[A == -3]
    

    In other words: for all the indices of A that have value -3, assign the values of B at the corresponding indices.

    0 讨论(0)
提交回复
热议问题