[R] if statement and for loop question

Kai Yang y@ngk@|9999 @end|ng |rom y@hoo@com
Sun May 30 18:28:52 CEST 2021


Hello List,I have a data frame which having the character columns:

| a1 | b1 | c1 | d1 |
| a2 | b2 | c2 | d2 |
| a3 | b3 | c3 | d3 |
| a4 | b4 | c4 | d4 |
| a5 | b5 | c5 | d5 |



I need to do: if a1 not = "Positive" and not = "VUS" then values of  b1, c1 and d1 will be zero out. And do the same thing for the a2 to a5 series.
I write the code below to do this. But it doesn't work. Would you please correct my code?
Thank you,
Kai


for (i in 1:5) 
{
  if (isTRUE(try$a[i] != "Positive" && try$a[i] != "VUS"))
  {
    try$b[i]== ''
    try$c[i] == ''
    try$d[i]== ''
  }
}


	[[alternative HTML version deleted]]



More information about the R-help mailing list