Re: [R] recode letters to numbers

2010-12-03 Thread Jim Lemon
On 12/04/2010 01:25 AM, Katharina Noussi wrote: Hello, I have a dataframe assigning various scores on around 20 variables to a list of countries. The scores are rated on a scale of (D, C, B, A) and there are also some not rated ones (NR) and others are left blank (NA). I now wanted to transfer t

Re: [R] recode letters to numbers

2010-12-03 Thread Phil Spector
Katharina - I think something like this may be helpful: z = data.frame(matrix(sample(c(LETTERS[1:4],'NR',NA),100,replace=TRUE),20,5)) codes = c(A=100,B=27,C=50,D=25,NR=0) newz = sapply(z,function(x)codes[x]) - Phil Spector

[R] recode letters to numbers

2010-12-03 Thread Katharina Noussi
Hello, I have a dataframe assigning various scores on around 20 variables to a list of countries. The scores are rated on a scale of (D, C, B, A) and there are also some not rated ones (NR) and others are left blank (NA). I now wanted to transfer the scores into numeric values (such as NR=0, D=