Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Julio,</p> <p>You mention that p1 and p2 have the same x-axis, but the reordering you do based on mean does not make them the same. <code>p1</code>'s axis goes "one --> two --> three" while <code>p2</code>'s axis goes "two --> one --> three". Is this intentional?</p> <p>Regardless, <code>ggplot</code> offers a few other solutions to combine these plots into one, namely <code>colour</code> and <code>faceting</code> (which you may have already tried?). The first step to either of these is to <code>melt</code> your data.frame to long format. We will identify the id variable "Type" and <code>melt</code> assumes the rest of the columns are to be <code>melted</code>.</p> <pre><code>test.m &lt;- melt(test, id.var = "Type") </code></pre> <p>A quick check of the structure of the new object indicates most everything is in line, except the levels for type are a bit out of whack:</p> <pre><code>&gt; str(test.m) 'data.frame': 12 obs. of 3 variables: $ Type : Factor w/ 3 levels "One","Three",..: 1 3 1 1 2 2 1 3 1 1 ... $ variable: Factor w/ 2 levels "RatingA","RatingB": 1 1 1 1 1 1 2 2 2 2 ... $ value : int 3 5 5 7 4 8 36 53 57 74 ... </code></pre> <p>So let's rearrage the levels:</p> <pre><code>test.m$Type &lt;- factor(test.m$Type, c("One", "Three", "Two"), c("One", "Two", "Three")) </code></pre> <p>Now for the plotting. With colour:</p> <pre><code>ggplot(test.m, aes(x = Type, y = value, group = variable, colour = variable)) + stat_summary(fun.y = "mean", geom = "point") </code></pre> <p>or with facets:</p> <pre><code>ggplot(test.m, aes(x = Type, y = value, group = variable)) + stat_summary(fun.y = "mean", geom = "point") + facet_grid(variable ~ ., scales = "free") </code></pre> <p>Note I used the <code>scales = "free"</code> argument in the faceting so that each plot has its' own scale. Simply remove that argument if that's not the effect you want.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload