try this:

s1 <- letters[1:10]
e <- LETTERS[1:10]
q <- c("a","a","c","b","d","d","a","e","b","a")

e[match(q, s1)]


I hope it helps.

Best,
Dimitris


patricia garcía gonzález wrote:
Hi all,
I am trying to create a vector with the information contained in a determined 
matrix. Let me explain myself. I have a vector like this:

        q <- c("a","a","c","b","d","d","a","e","b","a")

And a matrix like:

        s1 <- c("a","b","c","d","e","f","g","h","i","j")
        e <- c("A","B","C","D","E","F","G","H","I","J")
        s <- cbind( e, s1 )


The matrix s contains the correspondences between vector q and e. And I want a 
vector of elements of vector e, but in the order of q. The result should be 
like:

        q <-  c ("a","a","c","b","d","d","a","e","b","a")

        res<-c ("A","A","C","B","D","E","A","E","B","A")

So I have to take the elements of vector e and make a matching with elements in 
vector q. Any idea?Sorry If I didn't explain myself well.

Thanks

Patricia



_________________________________________________________________


        [[alternative HTML version deleted]]

______________________________________________
R-help@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 Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

______________________________________________
R-help@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.

Reply via email to