Hi,
I am sorry to bother again with this issue, but actually I avoided the
above loop problem by converting the data using as.numeric().
I don't know if I missed something in your answer above, but I didn't
get your solution to work, the result were (as above) 10 different
plots of each layer and not all 10 layers in one plot.
Now I need a similar plot with lines insted of points, and my
as.numeric solution does not work because I do not want all points to
be connected by a line, but:
The data points are in a 50x160 matrix, and I need each column of the
matrix to be one line (of length 50) in the plot which thus contains
160 single lines, plotted e.g. just against the numbers 1:50.
I also put the data into a list of length 160, with each list object
containing the vector I want to be one line, and tried to use melt (),
but I didn't get it to work neither.
I guess the solution must be quite simple but I'm stuck...
A simple example with a plot solution would be:
x = matrix(rnorm(50*160),ncol=160)
for (i in 1:160) x[,i]=x[,i]+i
plot(seq(1,50),x[,1],ylim=range(x),type="l")
for (i in 1:160) lines(seq(1,50),x[,i])
Can anybody help me finding a ggplot solution?
Many thanks in advance,
Silke.
On 22 Jan., 18:00, hadley wickham <
h.wick...@gmail.com> wrote:
> Ok, in that case you want the following in the body of your loop:
>
> m <- m + geom_point(aes(x=x[,i],y=y[,i]))
>
> Hadley
>
>
>
> On Thu, Jan 22, 2009 at 10:04 AM, silke <
silk...@gmail.com> wrote:
>
> > Thank you very much for your response, although the loop did not
> > really work for me as it returns 10 different plots, one of each
> > layer, and what I wanted is to have alllayersin the same plot.