try this: Data <- read.table(textConnection(" Alpha Beta Gamma Delta A .1 .2 .3 .4 B .2 .3 .4 .5 C .8 .9 .43 .13 D .13 .34 .34 .3"), header=TRUE) closeAllConnections()
par(mfrow=c(2,2)) for (i in colnames(Data)){ plot(Data[[i]],type="o",axes=F,xlab='', ylab='', ylim=c(0,1), main=i) axis(1,at=1:4,lab=c("A","B","C","D")) axis(2,at=seq(0, 1, .25)) # changed your axis to work } On Mon, Nov 9, 2009 at 3:38 PM, Koraelus <korae...@yahoo.com> wrote: > > I have three matrices with the same row and column names, but different data. > > e.g. > > Data > Alpha Beta Gamma Delta > A .1 .2 .3 .4 > B .2 .3 .4 .5 > C .8 .9 .43 .13 > D .13 .34 .34 .3 > > > For each column, I would like to create a separate plot on a single window. > I currently am using the cmd-line: > > windows() > par(mfrow=c(2,2)) > plot(Data$Alpha,type="o",axes=F,ann=F,ylim=c(0,1)) > axis(1,at=1:4,lab=c("A","B","C","D") > axis(2,at=.25*0:1) > plot(Data$Beta,type="o",axes=F,ann=F,ylim=c(0,1)) > axis(1,at=1:4,lab=c("A","B","C","D") > axis(2,at=.25*0:1) > etc. > > I would like to automate this as much as possible. I tried to write a > function, but clearly it would involve some sort of loop... I don't know how > to do anything like that. > > Thanks, > koraelus > -- > View this message in context: > http://old.nabble.com/Automating-Plot-Commands-using-a-Loop-tp26273268p26273268.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ 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.