Question

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.

Was it helpful?

Solution

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()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top