From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>

Date: Thu 15 Jul 2004 - 06:52:28 EST

*>
*

> [1] 2.952699

*>
*

*>
*

> [1] 5.026441

*>
*

*>
*

**> INDICES: A
**

*> [1] 2.813504
*

*> ------------------------------------------------------------------------------------------------------------
*

*>
*

*> INDICES: B
*

*> [1] 3.236663
*

*>
*

*>
*

> Error in FUN(X[[as.integer(1)]], ...) : couldn't find function "FUN"

*>
*

*>
*

*> I am using a Mac OS 10.3.4 running R 1.9.1
*

system i386, mingw32

status

major 1

minor 9.1

year 2004

month 06

day 21

language R

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 15 06:59:30 2004

Date: Thu 15 Jul 2004 - 06:52:28 EST

> Dear list friends

*>
**> I fail to understand how to find means for multiple groups using the
**> by() function. Help would be appreciated. Thanks.
**> Bill
**>
**>
**> x <- runif(20,0,10)
**> group <- rep(c("A","B"),10)
**> df <-data.frame(x,group)
**> #df #show the data
**>
**> rm(x,group)
**> attach(df)
**>
**> sd(x) # sd is defined
**> mean(x) #so is mean
**>
**> by(x,group,sd) #this works for both groups
**> by(x,group,mean) #this does not
**>
**>
**> produces this output:
**>
**>
*

>> x <- runif(20,0,10) >> group <- rep(c("A","B"),10) >> df <-data.frame(x,group) >> #df #show the data >> >> rm(x,group) >> attach(df) >> >> sd(x) # sd is defined

> [1] 2.952699

>> mean(x) #so is mean

> [1] 5.026441

>> >> by(x,group,sd) #this works for both groups

>> by(x,group,mean) #this does not

> Error in FUN(X[[as.integer(1)]], ...) : couldn't find function "FUN"

Hi Bill,

Works for me. Do you have a local "mean" defined? Try rm(mean) and re-try.

> R.version

_

platform i386-pc-mingw32

arch i386 os mingw32

system i386, mingw32

status

major 1

minor 9.1

year 2004

month 06

day 21

language R

--sundar

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 15 06:59:30 2004

*
This archive was generated by hypermail 2.1.8
: Wed 03 Nov 2004 - 22:54:58 EST
*