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.

1
  • 3
    It will be easier to help you if you post sample data and code. See this question and answers for tips: stackoverflow.com/q/5963269/602276 Commented Oct 7, 2011 at 14:01

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

2 Comments

OK thank you, but i wander how i can plot that for only one defined condition?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.