I am getting a error as Error: Unexpected '}' in    } when i run the following code. I have put closing brackets for every open bracket. But i am not sure why i get this error. find number of Columns & Rowsnumcol <- ncol(training_main)  numrow <- nrow(training_main)attach(training_main)  NA_count <- as.data.frame(sapply(training_main, function(x) sum(is.na(x))))  for(i in 1:numcol)    {       if (NA_count > 0)    {    for(j in 1:numrow)    {        if(is.na(training_main[j,i])          {            training_main[j,i] <- as.character(training_main[j,i])             training_main[j,i] <- Empty             training_main[j,i] <- as.factor(training_main[j,i])              print(empty printed)           }       }     }    }   Is the nested for -if - for - if as mentioned below  is allowed in R? That is the logic i have to use. Is there any other way i can run this code?
Error in R:: Error: Unexpected '}' in  }
r
Error is due to missing ')' in the second if statement in your code.if(is.na(training_main[j,i]) change to if(is.na(training_main[j,i]))