Skip to content
Back to formatted view

Raw Message

Message-ID: <43987DB2.9030501@lancaster.ac.uk>
Date: 2005-12-08T18:38:42Z
From: Barry Rowlingson
Subject: scoping issues?
In-Reply-To: <1134042425.4912.12.camel@localhost.localdomain>

tom wright wrote:

 > Browse[1]> mean(amps[1],amps[2],amps[3],amps[7],amps[8])
 > [1] 1

  For starters, this just returns mean(amps[1]). 'mean' computes the 
mean of the first argument, the others are slurped up by '...' and in 
this case thrown into the bin. You want to do 
mean(c(amps[1],amps[2],amps[3] and so on. Wrap them into a single vector.

  For main course, I think you can do it like this:

getAR <- function(v.amps){
   sv=sort(v.amps)
   sum(sv[1:3])/mean(sv[-(1:3)])
}

  - which computes the ratio of the sum of the three biggest over the 
mean of the remainder. Which I think is what your code looks like its 
trying to do!

  An example input/output would be nice. My code gives:

  > amps<-c(1,2,3,3,3,2,1)
  > getAR(amps)
  [1] 1.454545

  but I still dont know if that's what it should be!

  For dessert, I don't think its a scoping issue, I think you've not 
really explained what the problem is...

Baz