Supposing I want to turn the character “6000” into an integer. I could do it with
as.integer(6000)
However, let’s say that the user input was “6***”. This gives me an error. How do I convert
as.integer(6***)
into NA.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You would never write
as.integer(6000)oras.integer(6***).Instead you would write
or even more likely
where
strwas some text provided by user input. Perhaps read from a file and so on.In which case
will indeed return
NAifstris a character string containing6***.