[R] question on mean, sum
Berend Hasselman
bhh at xs4all.nl
Mon Nov 14 08:44:24 CET 2016
In addition to Petr's remarks:
- why are you doing sum(mtcars)[1]? Do you want the sum of first column of mtcars? In that case you should do sum(mtcars[,1]).
- similar remarks apply to your use of mean and sd.
Have you read an introduction to R?
Berend
> On 14 Nov 2016, at 04:01, mokuram at sina.com wrote:
>
> Hi,
> I am working on functions such as sum(), mean() ...
>> sum(mtcars)[1] 13942.2> mean(mtcars)[1] NAWarning message:In mean.default(mtcars) : NA> sd(mtcars)Error in is.data.frame(x) : ()'double'
> why got different reply?Is this a BUG for the current version of R?my version info:version.string R version 3.3.1 (2016-06-21)
>
> Thank you very much for the help.
> mokuram
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
More information about the R-help
mailing list