To graph panel data by group in R, one option is to use ggplot2. Here is an example code:
main.r482 chars17 lines
In this example, we first create an example panel data using the data.frame
function. We then reshape the data using the melt
function from the reshape2
package. This step is necessary to get the data in the long format required by ggplot. Finally, we use ggplot to create a line graph with separate facets for each variable, colored by group, and grouped by id. The result should be a graph with one panel per variable showing the evolution of each group over time.
gistlibby LogSnag