如何用 R 中同一数据集中的另一个值替换数据集中的值?

How to replace values in a dataset with another values in the same dataset in R?

假设我有以下名为 D 的数据集:

D <- read.csv("https://docs.google.com/uc?id=0B5V8AyEFBTmXQ1QwWVZuS3FXOHc&export=download")

D中,只要满足下面的条件,我希望D$n1被替换为D$N。我如何在 BASE R 中执行此操作?

if(D$t.type == 0 & is.na(D$n1) & is.na(D$n2))

这是你想要的吗?

D$n1[(D$t.type == 0 & is.na(D$n1) & is.na(D$n2))]=D$N[(D$t.type == 0 & is.na(D$n1) & is.na(D$n2))]