matplot(x,y) On 9/16/07, Raymond Wan <[EMAIL PROTECTED]> wrote: > > Hi all, > > I'm still a bit new to R and I'm trying to figure something out. I have > the solution but the solution is what a C programmer would do :-) and I > was wondering if someone could tell me the R way of doing it... > > What I have is a vector x of length |x|. And a matrix y of size m rows > and n columns where n = |x|. I want to plot m * n points on a graph so > that the x-coordinates are from x and the y coordinates are from y. > > I can plot x with the mean of each column of y as: plot (x,mean(y)). > But, to do what I want, I had to write this pair of for loops: > > for (i in 1:dim(y)[1]) { > for (j in 1:length(x)) { > points(x[j],y[i,j]) > } > } > > to add the points. I think there must be a better way using some > variant of apply or matlines. Even after reading the docs, I'm still > scratching my head a bit... Or maybe I copy x out so that it is of size > m by n?!? Any thoughts on what an R user would do here? Thanks! > > Ray > > ______________________________________________ > 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 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.