Displaying 1 result from an estimated 1 matches for "freqtot".
Did you mean:
freqtab
2008 Mar 04
1
help needed on function call
Hi there,
I am confused about fucntion call. After defining a function, I called it
within another function.
dt<-cars; #a copy of R internal dataset "cars" created;
dt$cat1<-ifelse(dt$speed<20,0,1);
dt$ind<-ifelse(dt$speed<15,1,2); #group variable;
freqtot <- function(data,var){
attach(data,warn.conflicts=FALSE)
x1 <- data.frame(table(var))
names(x1) <- c("Group","cnt")
x1$pct<-round(x1$cnt/nrow(data)*100,1)
return(x1)
}
freqgrp <- function(dt,var,grp,grpcnt){
xx<-freqtot(dt,var)
for(i in 1:grpcnt)...