How to resolve R error : non-numeric argument to binary operator?


I have just started learning R from scratch so i m getting trouble in execution of following code in RStudio. Please help…

a<-readline("enter any number ")



Try this -
a<-readline("enter any number ")
b<- as.numeric(a)+4




Yes, it worked!!!:slight_smile:
Thank you so much…

But will you please explain me the use of as.numeric() here??

Thank you.



Yeah so readline function read your input as a character type so as.numeric() just convert your input in a numeric form so that it could be summed up with other numbers.


Thank u for the explanation…:slight_smile:


how to ask here?