[R] Numbers

Christos Hatzis christos.hatzis at nuverabio.com
Fri Mar 6 16:32:23 CET 2009


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.
> 




More information about the R-help mailing list