[R] colMeans function
m@rc_@chw@rtz @end|ng |rom me@com
Wed Nov 4 14:46:12 CET 2020
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 is a data frame with a single column, so will have two dimensions with a row and column structure.
In the second case, flights$month is a single numeric vector within the data frame and does not have a row and column dimension structure.
If you used flights[], that would be equivalent to flights$month, in referencing a single numeric vector.
So, if you used:
you would see the difference.
> On Nov 4, 2020, at 8:26 AM, Engin Yılmaz <ispanyolcom using gmail.com> wrote:
> I use *flights* database library(nycflights13)
> The following code is working as
> * 6.54851*
> but other code is not working as
> *Error in colMeans(flights$month) : *
> * 'x' must be an array of at least two dimensions*
> *flights* is equal to the *month *column in database
> Engin YILMAZ
More information about the R-help