Suppose I have a vector of strings. I'd like to convert this to a vector of
numbers if possible. How can I tell if it is possible? 

as.numeric() will issue a warning if it fails. Do I need to trap this
warning? If so, how?

In other words, my end goal is a function that takes a vector of strings and
returns either a numeric vector or the original vector. Assuming this
doesn't already exist, then to write it I'd need a function that returns
true if its input can be converted to numeric and false otherwise.

Any suggestions will be appreciated.
-- 
View this message in context: 
http://www.nabble.com/how-to-tell-if-as.numeric-succeeds--tp23874936p23874936.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to