Reputation: 7517
Suppose I have the following Dataset called D
:
D <- read.csv("https://docs.google.com/uc?id=0B5V8AyEFBTmXQ1QwWVZuS3FXOHc&export=download")
In D
, whenever the below condition is met, I want D$n1
to be replaced with D$N
. How can I do this in BASE R?
if(D$t.type == 0 & is.na(D$n1) & is.na(D$n2))
Upvotes: 1
Views: 59
Reputation: 323226
Is this what you want ?
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))]
Upvotes: 1