Re: [R] colMeans function

2020-11-04 Thread Rui Barradas
Hello, No, flights[2] is *not* equal to flights$months. The former is a data.frame with only one column, therefore it has a dimension attribute. The latter is a column, a vector of the data.frame flights, it does not have the attribute dim set. The difference is very important, see what

Re: [R] colMeans function

2020-11-04 Thread Marc Schwartz via R-help
Hi, You might want to become familiar with the ?str and ?dim functions, which can help you identify the structure of the objects that you are passing to colMeans(). In the first case, flights[2] is a data frame with a single column, so will have two dimensions with a row and column structure.

Re: [R] colMeans function

2020-11-04 Thread Duncan Murdoch
On 04/11/2020 8:26 a.m., Engin Yılmaz wrote: Dear I use *flights* database library(nycflights13) The following code is working as colMeans(flights[2]) * 6.54851* but other code is not working as colMeans(flights$month) *Error in colMeans(flights$month) : * * 'x' must be an array of at

[R] colMeans function

2020-11-04 Thread Engin Yılmaz
Dear I use *flights* database library(nycflights13) The following code is working as colMeans(flights[2]) * 6.54851* but other code is not working as colMeans(flights$month) *Error in colMeans(flights$month) : * * 'x' must be an array of at least two dimensions* *flights[2]* is equal to