I believe your query is too vague to coherently (and generally) answer, but
have a look at ?outer  .

-- Bert

On Wed, May 15, 2013 at 12:57 PM, Hermann Norpois <hnorpois@gmail.com>wrote:

> Hello,
>
> I would like to do something with a matrix:
> 1) The columns should be compared pairwise.
> 2) And the result should be a matrix.
>
> I try to illustrate the problem with a testset.
>
> > m
>      rs1 rs2 rs3
> [1,]   1   1   1
> [2,]   0   1   0
> [3,]   2   0   1
> > dput (m)
> structure(c(1, 0, 2, 1, 1, 0, 1, 0, 1), .Dim = c(3L, 3L), .Dimnames = list(
>     NULL, c("rs1", "rs2", "rs3")))
> > which (m[,1] !=0&m[,2] != 0) #How many rows between two columns that are
> both non zero
>
> How can I automate the pairwise which-statement?
>
> As result I would like to have a matrix like this
>
>      rs1 rs2 rs3
> rs1
> rs2  1
> rs3  2    1
>
> Is there a tool in R that helps?
>
> Thanks
> Hermann
>
>         [[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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

	[[alternative HTML version deleted]]

