[R] Help. Import data

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jul 4 09:18:07 CEST 2003


On Fri, 4 Jul 2003, Fredrik Karlsson wrote:

> Hi Silika,
> 
> This is what I would do:
> 
> >df <- read.spss("datafile", to.data.frame=T)
> >for(i in c("age","income")){ #Add more if you like
> + df[[i]] <- as.numeric(df[[i]])
> +}

Please don't: that does not turn a factor into its numerical equivalent.
See the FAQ question I pointed Silika to (Q7.12 in the current version).  
It ends

   In any case, do not call `as.numeric()' or their likes directly.


-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list