Hi, I know the function LETTERS, but, now I have some letters to convert it in numbers, like A=1,B=2, etc... Is any function to do that? Atenciosamente, Leandro Lins Marino Centro de Avalia??o Funda??o CESGRANRIO Rua Santa Alexandrina, 1011 - 2? andar Rio de Janeiro, RJ - CEP: 20261-903 R (21) 2103-9600 R.:236 ( (21) 8777-7907 ( leandro at cesgranrio.org.br "Aquele que suporta o peso da sociedade ? precisamente aquele que obt?m as menores vantagens". (SMITH, Adam) ? Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE
try this: x <- c("A", "X", "F", "W", "G", "V", "L") match(x, LETTERS) I hope it helps. Best, Dimitris Leandro Marino wrote:> Hi, > > I know the function LETTERS, but, now I have some letters to convert it in numbers, like A=1,B=2, etc... Is any function to do that? > > Atenciosamente, > Leandro Lins Marino > Centro de Avalia??o > Funda??o CESGRANRIO > Rua Santa Alexandrina, 1011 - 2? andar > Rio de Janeiro, RJ - CEP: 20261-903 > R (21) 2103-9600 R.:236 > ( (21) 8777-7907 > ( leandro at cesgranrio.org.br > > "Aquele que suporta o peso da sociedade > ? precisamente aquele que obt?m > as menores vantagens". (SMITH, Adam) > > ? Antes de imprimir pense em sua responsabilidade e compromisso com o MEIO AMBIENTE > > ______________________________________________ > R-help at r-project.org 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.-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014
You can easily write a simple function to do that: letters2num <- function(x) { nletters <- 1:length(LETTERS) names(nletters) <- LETTERS nletters[x] }> x <- c("A", "X", "F", "W", "G", "V", "L") > letters2num(x)A X F W G V L 1 24 6 23 7 22 12 -Christos> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Leandro Marino > Sent: Friday, March 06, 2009 10:06 AM > To: r-help at r-project.org > Subject: [R] Numbers > > Hi, > > I know the function LETTERS, but, now I have some letters to > convert it in numbers, like A=1,B=2, etc... Is any function > to do that? > > Atenciosamente, > Leandro Lins Marino > Centro de Avalia??o > Funda??o CESGRANRIO > Rua Santa Alexandrina, 1011 - 2? andar > Rio de Janeiro, RJ - CEP: 20261-903 > R (21) 2103-9600 R.:236 > ( (21) 8777-7907 > ( leandro at cesgranrio.org.br > > "Aquele que suporta o peso da sociedade > ? precisamente aquele que obt?m > as menores vantagens". (SMITH, Adam) > > P Antes de imprimir pense em sua responsabilidade e > compromisso com o MEIO AMBIENTE > > ______________________________________________ > R-help at r-project.org 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. >