Skip to content
Prev 82454 / 398506 Next

scoping issues?

On Thu, Dec 08, 2005 at 06:47:05AM -0500, tom wright wrote:
This computes the mean of the set {1, 1, 2, 2, 1}, which is 7 / 5 = 1.4
This computes the mean of amps[1], i.e. of the set {1}, which is 1 / 1 = 1.

The remaining parameters are matched to the special variable length
formal parameter of the mean function, which, upon eventual dispatch
to mean.default are basically ignored, as far as I see.

Perhaps, you meant

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

which effectively calls mean with one argument of length 5, as opposed
to 5 arguments of length 1, as your call does.

Best regards, Jan