From: Barry Rowlingson <B.Rowlingson_at_lancaster.ac.uk>

Date: Fri 09 Dec 2005 - 05:38:42 EST

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 Fri Dec 09 06:06:30 2005

Date: Fri 09 Dec 2005 - 05:38:42 EST

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

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 Fri Dec 09 06:06:30 2005

*
This archive was generated by hypermail 2.1.8
: Fri 09 Dec 2005 - 09:31:26 EST
*