Hi Jim,

 

Thanks that is great stopped me going round the houses to achieve this.

 

 

Elliott

 

Message: 12

Date: Fri, 24 Jul 2009 11:32:55 -0400

From: "James W. MacDonald" <jmacdon@med.umich.edu>

Subject: Re: [BioC] Help with loop logic

To: elliott harrison <e.harrison@epistem.co.uk>

Cc: bioconductor@stat.math.ethz.ch

Message-ID: <4A69D427.4060003@med.umich.edu>

Content-Type: text/plain; charset=ISO-8859-1; format=flowed

 

Hi Elliott,

 

elliott harrison wrote:

> Hi BioC,

> 

>  

> 

> I'm working on a code to create a contrast matrix from the values
listed

> against array file in the targets file.

> 

>  

> 

> I can parse unique values from the input file ok but then I want to

> iterate over them to make the comparisons and matrix

> 

>  

> 

> Group1-group2,group1-group3,group2-group3

> 

>  

> 

>  

> 

> I have included my code that I think should get me close (perhaps need

> to strip trailing commas). However using this code the output string
is

> empty.

> 

>  

> 

> Can anyone spot what I'm missing?

 

Yes. Vectorization and the combn() function.

 

 > grp <- paste("Group", 1:4, sep = "")

 > ind <- t(combn(1:4, 2))

 > paste(grp[ind[,1]], grp[ind[,2]], sep = "-")

[1] "Group1-Group2" "Group1-Group3" "Group1-Group4" "Group2-Group3"

[5] "Group2-Group4" "Group3-Group4"

 

Best,

 

Jim

 



This message has been scanned for viruses by BlackSpider...{{dropped:6}}

