Error: unexpected symbol in:?



How do I fix this error in R as seen in PCA analysis walkthrough with BigMart Sales Data from Analytics Vidhya?

error: unexpected symbol in:
"combi$Item_Visibility<- ifelse(combi$Item_Visibility == 0, median(combi$Item_Visibility),

I am unfamiliar with ifelse and i think the problem is the comma. according to documentation, if else is not written properly but I don’t know how to write a better if else. i copied this code.

Thanks in advance!


in ifelse condition you need to give both if and else conditions . For example try below code

combi$Item_Visibility = ifelse(combi$Item_Visibility == 0, median(combi$Item_Visibility),combi$Item_Visibility)

i think it will work now


it is working now, appreciate your feedback!