I have a question about changing rownames. In the following function I am plotting the regression coeficients with their corresponding mean. Right now, the labels on the plot and the rownames in the dataframe are x1,x2,x3...etc. Is there a way to make the row names the same as the variable name entered into the formula? I.E. if x1 was a vector called opinions, it would be labeled opinions on the plot instead of x1. I have tried using variations of rownames(x)<- namevector but have not been successful. I keep getting a null. Any suggestions would be appreciated
Quadplot<-function(y, x1, x2, x3 = NULL, x4 = NULL,x5=NULL,x6=NULL,x7=NULL,x8=NULL,x9=NULL,x10=NULL, x11=NULL, x12=NULL, x13=NULL, x14=NULL) #section of code ommitted my.formula <- as.formula("y ~ x1 + x2 + x3+ x4+ x5+ x6+ x7+ x8+ x9+x10+x11+x12+x13+x14") outlm <- lm(my.formula) #section of code ommitted meanvec<-c(mean(x1,na.rm=TRUE),mean(x2,na.rm=TRUE),mean(x3,na.rm=TRUE),mean(x4,na.rm=TRUE),mean(x5,na.rm=TRUE),mean(x6,na.rm=TRUE),mean(x7,na.rm=TRUE),mean(x8,na.rm=TRUE),mean(x9,na.rm=TRUE),mean(x10,na.rm=TRUE),mean(x11,na.rm=TRUE) ,mean(x12,na.rm=TRUE) ,mean(x13,na.rm=TRUE) ,mean(x14,na.rm=TRUE)) } meanper<-meanvec/6 meanper1<-meanper*100 #This is the data frame created mf <- data.frame(Impact = abs(outlm$coef[-1]), Performance = meanper1) meanx<-mean(abs(outlm$coef[-1])) meany<-mean(meanper1) n<-length(meanvec) color<-rep("blue",n) color[(mf$Impact>meanx & mf$Performance>meany)]<-"green" color[(mf$Impact>meanx & mf$Performance<meany)]<-"red" color[(mf$Impact<meanx & mf$Performance>meany)]<-"gray" plot((mf),col=color,main="Perfomance vs. Impact",xlab="Impact",ylab="Performance", type = "n") points(mf, pch=21, bg=color, cex=4) text(x = mf$Impact, y = mf$Performance, labels = rownames(mf)) abline(h=mean(mf$Performance)) abline(v=mean(mf$Impact)) print(mf) } Thanks Derek ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html