Problem with mean()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with mean()

R help mailing list-2
Either I am doing something very stupid or my R installation has a glitch. What am I missing?
dd1  <- 50
dd2  <- 54

mean(dd1, dd2)
[1] 50  # wrong

(dd1 + dd2)/2
[1] 52 # correct

aa  <- c(48, 52, 56, 54, 52)

mean(aa)
[1] 52.4 # correct



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with mean()

Rui Barradas
Hello,

The first argument of mean is a vector, the dots argument is to be
"passed to or from other methods." (from ?mean)

Try instead

mean(c(dd1, dd2))


Hope this helps,

Rui Barradas

Às 17:39 de 21-07-2018, John Kane via R-help escreveu:

> Either I am doing something very stupid or my R installation has a glitch. What am I missing?
> dd1  <- 50
> dd2  <- 54
>
> mean(dd1, dd2)
> [1] 50  # wrong
>
> (dd1 + dd2)/2
> [1] 52 # correct
>
> aa  <- c(48, 52, 56, 54, 52)
>
> mean(aa)
> [1] 52.4 # correct
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with mean()

Duncan Murdoch-2
In reply to this post by R help mailing list-2
On 21/07/2018 12:39 PM, John Kane via R-help wrote:
> Either I am doing something very stupid or my R installation has a glitch. What am I missing?
> dd1  <- 50
> dd2  <- 54
>
> mean(dd1, dd2)
> [1] 50  # wrong

Read the help page ?mean.  You are specifying the parameters x and trim.

Duncan Murdoch

>
> (dd1 + dd2)/2
> [1] 52 # correct
>
> aa  <- c(48, 52, 56, 54, 52)
>
> mean(aa)
> [1] 52.4 # correct
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with mean()

Jeff Newmiller
In reply to this post by R help mailing list-2
Read ?mean.

Look at the argument list.

The mean function only applies to the first argument.

On July 21, 2018 9:39:42 AM PDT, John Kane via R-help <[hidden email]> wrote:

>Either I am doing something very stupid or my R installation has a
>glitch. What am I missing?
>dd1  <- 50
>dd2  <- 54
>
>mean(dd1, dd2)
>[1] 50  # wrong
>
>(dd1 + dd2)/2
>[1] 52 # correct
>
>aa  <- c(48, 52, 56, 54, 52)
>
>mean(aa)
>[1] 52.4 # correct
>
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.