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 clas

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 lea

[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 th

Re: [R] colmeans not working

2012-12-23 Thread arun
24739  8.591345 13.773817  5.386458  2.847495  5.448138    #     9    10    11    12  #9.266519  7.63 15.249745 14.335008 Hope it helps. A.K. From: eliza botto To: "smartpink...@yahoo.com" Cc: "r-help@r-project.org"

Re: [R] colmeans not working

2012-12-23 Thread arun
$WW #[1]  2.153747  2.130745  5.828026 12.909944 A.K. From: eliza botto To: "smartpink...@yahoo.com" Cc: "r-help@r-project.org" Sent: Sunday, December 23, 2012 9:10 PM Subject: RE: [R] colmeans not working Dear Arun, on having a bir

Re: [R] colmeans not working

2012-12-23 Thread arun
tto To: bbol...@gmail.com; r-h...@stat.math.ethz.ch Cc: Sent: Sunday, December 23, 2012 7:48 PM Subject: Re: [R] colmeans not working Dear Ben,Thanks for replying but its still not working.your code was>lapply(res,colMeans)but i want to use "res1" instead of "res". when i

Re: [R] colmeans not working

2012-12-23 Thread eliza botto
:40:15 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] colmeans not working > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org; bbol...@gmail.com > > Hi Eliza, > > I tried with the example you gave. Couldn't reproduce the error. > > >

Re: [R] colmeans not working

2012-12-23 Thread eliza botto
> Date: Sun, 23 Dec 2012 17:40:15 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] colmeans not working > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org; bbol...@gmail.com > > Hi Eliza, > > I tried with the example you gave. Couldn't reproduce

Re: [R] colmeans not working

2012-12-23 Thread arun
lapply(res,function(x) rowMeans(x[,-1])) #$Sa #  1   2   3   4   5   6   7   8   9  10  11  12 #NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN # #$Ta   #     1    2    3 #2.40 2.40 2.33 A.K. - Original Message - From: eliza botto To: "r-help@r-project.org&q

Re: [R] colmeans not working

2012-12-23 Thread eliza botto
Dear Ben,Thanks for replying but its still not working.your code was>lapply(res,colMeans)but i want to use "res1" instead of "res". when i did use it, i got same error.eliza > To: r-h...@stat.math.ethz.ch > From: bbol...@gmail.com > Date: Mon, 24 Dec 2012

Re: [R] colmeans not working

2012-12-23 Thread Ben Bolker
eliza botto hotmail.com> writes: > Dear useRs,You must all the planning for the christmas, but i am > stucked in my office on the following issue i had a file containg > information about station name, year, month, day, and discharge > information. i opened it by using following command > > dat

[R] colmeans not working

2012-12-23 Thread eliza botto
[text file is also attached in case you find the format of email difficult to understand] Dear useRs,You must all the planning for the christmas, but i am stucked in my office on the following issue i had a file containg information about station name, year, month, day, and discharge informatio

Re: [R] colMeans()

2009-09-28 Thread Jim Lemon
On 09/28/2009 10:47 PM, Matteo Mattiuzzi wrote: Hello, I use the function rowMeans(x,na.rm=T). The result is the mean of valid values in each row, with NA removed. A for me very important information is, from how many valid "n" this mean has computed. The thing is, that I apply this function on

[R] colMeans()

2009-09-28 Thread Matteo Mattiuzzi
Hello, I use the function rowMeans(x,na.rm=T). The result is the mean of valid values in each row, with NA removed. A for me very important information is, from how many valid "n" this mean has computed. The thing is, that I apply this function on many millions of rows, so the time it takes is

Re: [R] colMeans in a data.frame with numeric and character data

2008-03-27 Thread Gabor Grothendieck
summaryBy in the doBy package can do that. The builtin iris data set has 4 numeric columns and one factor column: > library(doBy) > summaryBy(.~1, iris, fun = mean, keep = TRUE) Sepal.Length Sepal.Width Petal.Length Petal.Width 1 5.843.0573333.7581.199333 On Thu, Mar 2

Re: [R] colMeans in a data.frame with numeric and character data

2008-03-27 Thread Douglas Bates
On Thu, Mar 27, 2008 at 3:05 PM, Dimitris Rizopoulos <[EMAIL PROTECTED]> wrote: > try this: > > dat <- data.frame(x = rnorm(10), y = rexp(10), z = letters[1:10]) > colMeans(data.matrix(dat[sapply(dat, is.numeric)])) Alternatively > sapply(dat, mean) x y z -0.5260131

Re: [R] colMeans in a data.frame with numeric and character data

2008-03-27 Thread Dimitris Rizopoulos
try this: dat <- data.frame(x = rnorm(10), y = rexp(10), z = letters[1:10]) colMeans(data.matrix(dat[sapply(dat, is.numeric)])) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuv

[R] colMeans in a data.frame with numeric and character data

2008-03-27 Thread Diogo André Alagador
Hi all, I would like to know if it is posible by, someway, to get colMeans from a data.frame with numeric as well as character data, dispersed all over the object. Note that I would like to get colMeans neglecting character data. I am really in need of some function proceeding in that way… Al