[R] Reformatting data into data frame and plotting it in ggplot2

Tribo Laboy tribolaboy at gmail.com
Fri Feb 1 02:59:36 CET 2008


Hello,

I am sure this must have been asked before, but my nabble search did
not turn anything useful. Just pointer where to look will also be
nice.

So, I have the following data:

x_test1 <- c(1:10)
y_test1<-rnorm(10)
x_test2 <- c(1:15)
y_test2<-rnorm(15)
x_test3 <- c(1:20)
y_test3<-rnorm(20)

These represent time series or frequency spectra, possibly sampled
with different sampling frequencies, but obviously having different
lengths. The physical meaning of X and Y is the same for the three
series above - as I said, time or frequency in my case.
Now I want to plot them on the same graph with the legend "test1",
"test2" and "test3".

ggplot PDF manual says that the data frame is the preferable format
for the data to plot. I guess that turning the above data into a data
frame would be useful in many other situations as well. So how can I
do that?



More information about the R-help mailing list