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

From: Tribo Laboy <tribolaboy_at_gmail.com>
Date: Fri, 1 Feb 2008 10:59:36 +0900


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)
x_test2 <- c(1:15)
x_test3 <- c(1: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?

R-help_at_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. Received on Fri 01 Feb 2008 - 11:49:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Feb 2008 - 12:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive