Thank you, it works.
by the way, sometime I guess *apply functions act like loop, because
when I apply a complicated function, they run slowly and one by one.

On Tue, Jun 12, 2012 at 3:39 PM, Rui Barradas <ruipbarra...@sapo.pt> wrote:
> Hello,
>
> Try
>
> sapply(seq_len(ncol(mt2)), function(j) mt1[mt2[, j], j])
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 12-06-2012 17:19, Zhenjiang Lan escreveu:
>
>> mt1:
>>      [,1] [,2] [,3]
>> [1,] "G"  "A"  "A"
>> [2,] "C"  "T"  "C"
>>
>> mt2:
>>      [,1] [,2] [,3]
>> [1,]    1    2    2
>> [2,]    2    1    2
>> [3,]    2    2    2
>> [4,]    1    1    1
>
>

______________________________________________
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