Hi All,

I have a data frame of three columns, all of which names. The names in the 
three 
  cols overlap up to a point, so I might have *Harry* in all three columns, 
*Tom* in cols 1 and 3 and *Bob* in col 3 only.

harry   paul    bob
anita   harry   tom
frank   jack    harry
tom     pete    ben
....    

I want to turn the names into numbers, BUT I want the numeric code for, say, 
*Harry*, to be the same on all columns.

Doing

cbind(as.numeric(col1), as.numeric(col2), as.numeric(col3))

does not work because the factors are different in each column, hence they get 
a 
different number even though the name is the same.

Ideas?

Cheers

Federico

-- 
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] imperial.ac.uk
f.calboli [.a.t] gmail.com

______________________________________________
R-help@stat.math.ethz.ch 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