Try this: suppressWarnings(as.numeric("A"))
On Fri, Apr 9, 2010 at 7:22 PM, Andrew Yee <y...@post.harvard.edu> wrote: > I'm interested in testing whether or not a character string is numeric or > not as follows: > > is.na(as.numeric('3')) # returns F > is.na(as.numeric('A')) # I'd like this to return T without issuing a warning > about NAs introduced by coercion. > > I guess you could suppress the warning with options(warn=-1), but I was > wondering if there's an alternative. Or perhaps an alternative that doesn't > use as.numeric()? > > Thanks, > Andrew > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > ______________________________________________ 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.