[R] converting among modes

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jul 27 19:44:43 CEST 2001


On Fri, 27 Jul 2001, Martin Henry H. Stevens wrote:

> Windows 2000, R 1.3.0
>
> I have been given a data set (ASCII tab delimited) in which many variables
> that are supposed to be numeric actually contain characters. I would be
> happy to have those character entries disappear and become NA.
>
> When I use read.table and then attempt to convert these using as.numeric(),
> of course it doesn't work, and I get the ASCII? representation? maybe? When

Yes, `of course'.  You need as.numeric(as.character()) since those columns
are factors. (See the FAQ item 7.13.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list