dat <- read.table("/usr/local/misc/Ramanathan/data/ascii/unix/data3-2") y <- dat[,1] x <- dat[,2] b <- lm(y~x)$coefficients xmin <- min(x) xmax <- max(x) xfig("engel.fig", onefile=T) plot(x,y,type="n", xlab="Income", ylab="Health Expenditure", main="",col=1) text(x[1],y[1],"##%% depth=40",0) text(50,80, paste("$\\widehat{HealthExp}=",round(b[1],3),"+", round(b[2],3),"Income$",sep=""), 0,col=1) text(x[1],y[1],"##%% depth=80",0) points(x, y, pch=19, col=2) text(x[1],y[1],"##%% depth=70",0) text(500,20,paste("$\\color{blue}n=",length(y),"$",sep="")) text(x[1],y[1],"##%% depth=60",0) lines(c(xmin,xmax),b[1]+b[2]*c(xmin,xmax),col=4,lwd=6,lty=1) dev.off() system("fig2pstricks -o engel.tex -c --prosper engel.fig -d -T \"Income and Health Expenditure\"") system("latex engel && dvips engel && ps2pdf engel.ps") system("xpdf -z 0 engel.pdf")