title: R panel time series mean plot
body: <p>I have panel data with ID=1,2,3... year=2007,2008,2009... and a factor foreign=0,1, and a variable X. </p>
  
  <p>I would like to create a time series plot with x-axis=year, y-axis=values of X that compares the average (=mean) development of each factor over time. As there are 2 factors, there should be two lines, one solid and one dashed.</p>
  
  <p>I assume that the first step involves the calculation of the means for each year and factor of X, i.e. in a panel setting. The second step should look something like this:</p>
  
  <pre><code>ggplot(data, aes(x=year, y=MEAN(X), group=Foreign, linetype=Foreign))+geom_line()+theme_bw() 
  </code></pre>
  
  <p>Many thank. </p>