[Rd] to overcome error while computing sd for each subset of data (PR#9931)
anjalishitole at yahoo.co.in
anjalishitole at yahoo.co.in
Thu Sep 27 13:22:41 CEST 2007
Full_Name: Anjali Shitole
Version: R 2.5.1
OS:
Submission from: (NULL) (202.141.157.91)
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 =
"NA",fill=TRUE)
> 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.
More information about the R-devel
mailing list