Re: [R] from character to numeric over multiple columns

From: Federico Calboli <>
Date: Fri 21 Jul 2006 - 21:02:02 EST

Prof Brian Ripley wrote:
> Are the columns factors or character? I'll try to write code that copes
> with both:
> nm <- unique(c(as.character(col1), as.character(col2), as.character(col3)))
> DF[] <- lapply(DF, function(x) match(x, nm))


it worked.


Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193

f.calboli [.a.t]
f.calboli [.a.t]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Jul 21 21:14:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 22:17:53 EST.

Mailing list information is available at Please read the posting guide before posting to the list.