[R] plotting lm coeficients with their means
Derek Margetts
dm60062003 at yahoo.com
Mon Nov 8 17:39:06 CET 2004
I am trying to write a function that will run a linear
model and plot the regression coeficients with their
corresponding means. I am having two problems. I can
get the plot with the function below, but I am having
trouble labeling the points.
function(y,x1,x2,x3,x4){
outlm<-lm(y~x1+x2+x3+x4)
imp<-as.data.frame(outlm$coef[-1])
meanvec<-c(mean(x1),mean(x2),mean(x3),mean(x4))
out<-list(imp,meanvec)
mf<-as.data.frame(out)
plot((mf),xlab="Impact",ylab="performance")
abline(h=mean(meanvec))
abline(v=mean(imp))
}
Problem #2: If I only input x1,x2,and x3 how do I get
the function to ingnore the 4th instead of giving me
the unused argument error?
Thanks
Derek
More information about the R-help
mailing list