On Thu, Mar 12, 2015 at 2:43 PM, Steve Taylor <steve.tay...@aut.ac.nz> wrote:
> How about letting a standard function decide which are numbers:
>
> which(!is.na(suppressWarnings(as.numeric(myvector))))
>
> Also works with numbers in scientific notation and (presumably) different 
> decimal characters, e.g. comma if that's what the locale uses.

One problem is that Adrian wanted, for some reason, to exclude numbers
such as "2." but accept "2.0" . That is, no unnecessary trailing
decimal point. as.numeric() will not fail on "2." since that is a
number. The example grep() specifically excludes this by requiring at
least one digit after any decimal point.

-- 
He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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