Hi All,
I want to write IF function for string variable. if it matches i should create new column.
If then else function.
Am not able to write code please help me.
Hi All,
I want to write IF function for string variable. if it matches i should create new column.
If then else function.
Am not able to write code please help me.
You have given us very little information to work with. Please make a Reproducible Example if the code below does not fix your problem. To learn about reproducible examples, you can read this post:
Let's assume you have a data frame named DF and a variable named MyVar. This code makes a new column in DF named alpha with a value of 1 in every row if MyVar is equal to alpha.
if (MyVar == "alpha") {
DF$alpha <- 1
}
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.