Simple IF statement in R

I haven't tested this yet.

In SAS:

If A=2 then B=3;

In R:

data[which(A==2),"B"] = 3

or

data[which(data[,"A"]==2),"B"] = 3

 

CategoriesR

Leave a Reply