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

-- 
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: jgrn...@hotmail.com, Gchat: jgrn307, Skype: jgrn3007

        [[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.

Reply via email to