[R] data.frame, ggplot vs matplot
Ben Bolker
bolker at ufl.edu
Tue Oct 30 22:55:50 CET 2007
baptiste Auguié-2 wrote:
>
> Hello,
>
>
> I've been trying to use ggplot, but I cannot seem to get my data in
> the correct form. I usually have a vector x, and a matrix y and I
> would usually use matplot(x,y) to plot the columns of y against x.
>
> Now, if i understand correctly, I should cast x and y into a
> data.frame and do something like ggplot(x,y,data=data). I think I'm
> missing something here: do I really need to reshape y into a single
> vector, replicate x accordingly, and put both vectors in a data frame?
>
> I've tried it, but the reshape function is still very obscure to me.
> Any help appreciated!
>
> Small example:
>
> x<-seq(from=1,by=1,length=10)
> y<-sin(x)%*%t(x)
> columns<-c(1:10)
>
> matplot(x,y)
>
> legend("topleft", "(x,y)", columns)
>
>
dataL = melt(dataS,id="x")
qplot(x,value,data=dataL)
qplot(x,value,data=dataL,colour=variable)
cheers
Ben Bolker
--
View this message in context: http://www.nabble.com/data.frame%2C-ggplot-vs-matplot-tf4721042.html#a13498585
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list