2

I'm using ggplot2 with the faceting option to plot several results of a data.frame.

It's a data.frame with three factors :

  • participant (N) with 6 levels;
  • condition (C) with 6 levels;
  • stimuli (S) with 10 conditions.

I plot the results of one participants in one condition using the subset function and then I facet with ggplot. However, I was wondering if there was an easier solution in ggplot2?

Thanks for any help, I'm currently learning R and ggplot2.

tonytonov
  • 25,060
  • 16
  • 82
  • 98
  • 3
    It will be easier to help you if you post sample data and code. See this question and answers for tips: http://stackoverflow.com/q/5963269/602276 – Andrie Oct 07 '11 at 14:01

1 Answers1

1

It sounds like you're trying to ask how to set up a two-way facet. I'm going to guess that 'stimuli is your predictor variable.

One way is like this:

ggplot( mydata, aes( x = stimuli, y = my.response) +

        facet_wrap( condition ~ participant) +

        geom_line() 

or

        geom_point()
Chris
  • 418
  • 3
  • 10
  • OK thank you, but i wander how i can plot that for only one defined condition? –  Oct 08 '11 at 13:09
  • You can remove one of the variables in the facet_wrap statement, but some sample code showing what you've tried so far would be helpful. – Chris Oct 09 '11 at 14:49