Yep, type.convert was exactly what I was looking for (with as.is=TRUE).
 Thanks!


On Thu, Mar 21, 2013 at 1:31 PM, Prof Brian Ripley <ripley@stats.ox.ac.uk>wrote:

> On 21/03/2013 18:20, Jonathan Greenberg wrote:
>
>> Given an arbitrary set of character vectors:
>>
>> myvect1 <- c("abc","3","4")
>> myvect2 <- c("2","3","4")
>>
>> I would like to develop a function that will convert any vectors that can
>> be PROPERLY converted to a numeric (myvect2) into a numeric, but leaves
>> character vectors which cannot be converted (myvect1) alone.  Is there any
>> simple way to do this (e.g. some function that tests if a vector is
>> coercible to a numeric before doing so)?
>>
>> --j
>>
>
> ?type.convert
>
> It does depend what you mean by 'properly'.  Can
> "123.456789012344567890123455" be converted 'properly'?  [See the NEWS for
> R-devel.]
>
> --
> Brian D. Ripley,                  ripley@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~**ripley/<http://www.stats.ox.ac.uk/~ripley/>
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
> ______________________________**________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
607 South Mathews Avenue, MC 150
Urbana, IL 61801
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

	[[alternative HTML version deleted]]

