Re: [R] question on mean, sum

2016-11-14 Thread Jim Lemon
Hi mokuram, As others have noted, you will profit from a bit more knowledge about "extraction": sum(mtcars) [1] 13942.2 This works because you have "extracted" the first column of the "mtcars" data frame _as a data frame_ mtcars[1] mpg Mazda RX4 21.0 Mazda RX4 Wag

Re: [R] question on mean, sum

2016-11-13 Thread Berend Hasselman
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,

Re: [R] question on mean, sum

2016-11-13 Thread PIKAL Petr
) Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > moku...@sina.com > Sent: Monday, November 14, 2016 4:01 AM > To: r-help <r-help@r-project.org> > Subject: [R] question on mean, sum > > Hi, > I am working

[R] question on mean, sum

2016-11-13 Thread mokuram
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