search for: elecregtipo

Displaying 1 result from an estimated 1 matches for "elecregtipo".

Did you mean: elecregtipos
2012 Mar 18
1
Help with dlply, loop and column names
...e in this variable a regression (psoe~total), but split up by tipo. I have the main idea of using dlply from the plyr vignette. But when I try to put all this in a loop I'm coming into trouble and I'm at the moment really confused how to solve this problem: I have the following function: elecregtipos <- function(y){ z<-dlply(asturias.gen2011, .(tipo), function(x) lm(x[,y]~x$edad.media)) # rsq<-function(x) summary(x)$r.squared # bcoefs<-ldply(z, function(x) c(coef(x), rsquare=rsq(x))) # return (bcoefs) return(z) } And I try to call it with: for (y in c("u...