HI, Perhaps: zscore<-function(x, y, data) { lm<-lm( y ~ x , ...) z <- coef(lm)/sqrt(diag(vcov(lm))) return(z) }
On 23/10/2007, Peter Tait <[EMAIL PROTECTED]> wrote: > > Hi, > > I am writing a basic function to extract the z scores for some linear > regression coefficients: > > zscore<-function( y, x) { > lm<-lm( y ~ x ) > z <- coef(lm)/sqrt(diag(vcov(lm))) > return(z) > } > > I would like to pass a dataframe to the function as a argument so the > function call changes from > > zscore(df$y1,df$x1) > > to > > zscore(y1,x1,data=df) > > but I am not sure how to reference the data frame inside the function. > > Are there any good free references on how to program functions in R > (besides > the official manuals) > > Thanks for your help. > Cheers > Peter > > ______________________________________________ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ R-help@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.