From: Srinivas Iyyer <srini_iyyer_bio_at_yahoo.com>

Date: Thu 06 Jul 2006 - 22:18:47 EST

1 Apple S

2 Apple A

3 Apple O

4 Orange A

5 Orange O

6 Orange S

7 Mango M

8 Mango A

9 Mango S

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 06 22:23:48 2006

Date: Thu 06 Jul 2006 - 22:18:47 EST

hi:

I have matrix with dimensions(200 X 20,000). I have another file, a tab-delim file where first column variables are row names and second column variables are column names.

*> tmat
*

Apple Orange Mango Grape Star

A 0 0 0 0 0 O 0 0 0 0 0 M 0 0 0 0 0 G 0 0 0 0 0 S 0 0 0 0 0

> tb # tab- delim file.

V1 V2

1 Apple S

2 Apple A

3 Apple O

4 Orange A

5 Orange O

6 Orange S

7 Mango M

8 Mango A

9 Mango S

I have to read each line of the 'tb' (tab delim file), take the first variable, check if matches any rowname of the matrix. Take the second variable of the row in and check if it matches any column name. If so, put 1 else leave it.

The following is a small piece of code that, I felt is a solutions. However, since my original matrix and tab-delim file is very very huge, I am not sure if it is really doing the correct thing. Could any one please help me if I am doing this correct.

> for(i in 1:length(tb[,1])){

+ r = tb[i,1] + c = as.character(tb[i,2]) + tmat[rownames(tmat)==c,colnames(tmat)==r] <-1 + }

*> tmat
*

Apple Orange Mango Grape Star

A 1 1 1 0 0 O 1 1 0 0 0 M 0 0 1 0 0 G 0 0 0 0 0 S 1 1 1 0 0

Thanks.

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 06 22:23:48 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Fri 07 Jul 2006 - 00:14:45 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*