Re: [R] letters to numbers conversion

About this list Date view Thread view Subject view Author view Attachment view

From: Andrew C. Ward (s195404@student.uq.edu.au)
Date: Fri 02 May 2003 - 14:42:41 EST


Message-id: <1051850561.3eb1f7413b6f8@my.uq.edu.au>

How about the following?
   t1 <- matrix(letters[1:9], nrow=3, byrow=TRUE)
   t1
   t2 <- t(apply(t1, 1, function(x) match(x, letters)))
   t2

Regards,

Andrew C. Ward

CAPE Centre
Department of Chemical Engineering
The University of Queensland
Brisbane Qld 4072 Australia
andreww@cheque.uq.edu.au
  
   
Quoting Robin Hankin <r.hankin@auckland.ac.nz>:

> Hello List
>
> How do I turn
>
> R> simple.example.alphabetic
> [,1] [,2] [,3]
> [1,] "a" "b" "c"
> [2,] "d" "e" "f"
> [3,] "g" "h" "i"
>
> into
>
> R> simple.example.numeric
> [,1] [,2] [,3]
> [1,] 1 2 3
> [2,] 4 5 6
> [3,] 7 8 9
>
> [ie "a" becomes 1, ..., "z" becomes 26]
> ?
>
>
>
>
>
>
> --
>
> Robin Hankin, Lecturer,
> School of Geography and Environmental Science
> Tamaki Campus
> Private Bag 92019 Auckland
> New Zealand
>
> r.hankin@auckland.ac.nz
> tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:44 EST