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

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 25 Feb 2008 10:55:07 -0500

Please give minimal reproducible examples. The data and a test driver were missing. See last line to every message to r-help.

The problem is discussed here:
http://tolstoy.newcastle.edu.au/R/help/06/08/32017.html

On Mon, Feb 25, 2008 at 10:05 AM, vincent chouraki <vchouraki_at_yahoo.fr> wrote:
> 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"))))
>
> temp
>
> }
>
> 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.
>
>



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 - 16:03:48 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 - 17: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