[R] "by" function "half-working" when used in a custom function

From: vincent chouraki <vchouraki_at_yahoo.fr>
Date: Mon, 25 Feb 2008 15:05:59 +0000 (GMT)

Dear R users,

I'm trying to save the results of separate logistic regression analyses of a dataset according to a categorical factor. For that, I first used a "by" function such as following :

temp <- by( data, data$categorical.factor , function(x) summary( glm( formula = data$var1 ~ data$var2 , data = x , family = binomial("logit"))))

and it worked perfectly well

Next I tried to create a custom function that contains the latter syntax

regtab <- function(category, arg1, arg2 , data){

  temp <-by( data, category , function(x) summary( glm( formula= arg1 ~ arg2 , data=x , family = binomial("logit"))))



the resulting object of this function is a list with the correct subgroup categories as its element's names but with the results of the entire dataset logistic regression as its elements.

I can't figure out what's going on. Do you have any clues ?

Many thanks in advance,  

Vincent Chouraki,
Interne de Santé Publique,
CHRU-Lille, France.

        [[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 25 Feb 2008 - 15:11:52 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 Mon 25 Feb 2008 - 16:30:16 GMT.

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

list of date sections of archive