[Rd] to overcome error while computing sd for each subset of data (PR#9931)

From: <anjalishitole_at_yahoo.co.in>
Date: Thu, 27 Sep 2007 13:22:41 +0200 (CEST)

Full_Name: Anjali Shitole
Version: R 2.5.1
Submission from: (NULL) (

I want to compute coefficient of variation for each subset of data. Each subset is heterogeneous means number of rows in each subset are different.These all subsets are in one dataset situated one by one. i have used aggregate command to calculate mean for each subset. But same command for calculating sd gives error see the following program,
> a<-read.table("c:/mri/data/ratioinput.txt",header=T, na.strings =
> dim(a)

[1] 32515 27
> BusinessRisk<-a[,16]/(a[,26]/a[,27])
> a1<-a[,1:3]
> a2<-cbind(a1,BusinessRisk)
> c1<-aggregate(BusinessRisk,list(a2[,1]),mean)
> names(a)

 [1] "Co_Code"        "Co_Name"        "Year"           "TotSholderFund"
 [5] "TotLiab"        "NetBlock"       "Investments"    "Inventories"   
 [9] "SundryDebts"    "CashandBank"    "TotCurrAssets"  "CurrLiab"      
[13] "TotCurrLiab"    "TotAssets"      "NetSales"       "OpPft"         
[17] "Interest"       "GrossPft"       "AdjNetPft"      "Dividend"      
[21] "PrefDivi"       "EquityPaidUp"   "CurrentAssets"  "PBIT"          
[25] "TotExpen"       "Equity"         "FaceValue"     

> c2<-aggregate(BusinessRisk,list(a2[,1]),sd(BusinessRisk,na.rm=TRUE))
Error in FUN(X[[1L]], ...) : argument "INDEX" is missing, with no default

Please help me to overcome this error.

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 28 Sep 2007 - 06:28:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 02 Oct 2007 - 14:41:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.