RE: [R] proportional matrix rows

2005-02-07 Thread Martin Chlond
Robin

The attached script works but it ain't pretty/

Martin
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.

 
  
__
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

RE: [R] proportional matrix rows - with attachment

2005-02-07 Thread Martin Chlond
Sorry! Something went wrong with the attachment in my previous post.

Here it is.
---


intmult - function(X)

{
  # extract columns with non-zero top cell
  X1 - X[,which(X[1,]!=0)]
  
  # look for integer multiples in reduced table
  m - nrow(X1);n - ncol(X1)
  D - matrix(X1[1,],m,n,byrow=T)
  X2 - X1/D
  ind - which(rowSums(X2==rowMeans(X2))==n)
  
  # build new table of integer multiples
  X3 - X[ind,]
  
  # remove rows that contain non-zero(s) below top zero
  ind - which(X3[1,]==0)
  lind = length(ind)
  temp - X3[,ind]==0
  ind2 - which(rowSums(temp)==lind)
  X4 - X3[ind2,]
}

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.

__
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