Skip to content

Chars as numbers

4 messages · Josef Eschgfaeller, Tobias Muhlhofer, vincent +1 more

#
Is there a proper function for transforming
a character to a number instead of using

   i=match('c',letters)
   # 3

Thanks.
Josef Eschgf??ller
#
Josef,

Not sure if this is exactly what you mean, but there is a generic function

as()

to which you can then specify "numeric" as an argument and which then 
coerces stuff into numeric format.

Tobias
Josef Eschgfaeller wrote:

  
    
#
Josef Eschgfaeller wrote:
I'd suggest to use the above if you really mean it. Note that 
"transforming a character to a number" is not well defined, because you 
have to think about encodings and characters at first. See the article 
by Brian Ripley in the most recent issue of R News, for example.

Uwe Ligges