Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11751

How do I make an R graph that splits data horizontally and vertically?

$
0
0

Below is a simplified version of my data. I want to plot the Means using vertical bars with ggplot() + geom_bar. There are a few things I want to do.

  • I want to separate the data where I have the data grouped vertically (=side by side/beside each other/in columns) according to Vfront (all "front" data on left, all "back" data on right).

  • I also want to separate the data where I have the data grouped horizontally (on top of each other/in rows) according to Manner (all "Stop" on top row, all "Fric" on bottom row).

  • Additionally, I want to have the different MedDors grouped per Target (in the NA, cor, incor, X order).

Target  Manner  Vfront  MedDor  Meanp       Stop    front   NA      0.60p       Stop    back    NA      0.59p       Stop    front   cor     0.58p       Stop    back    cor     0.56p       Stop    front   incor   0.52p       Stop    back    incor   0.52p       Stop    front   X       0.24p       Stop    back    X       0.52b       Stop    front   NA      0.42b       Stop    back    NA      0.39b       Stop    front   cor     0.37b       Stop    back    cor     0.42b       Stop    front   incor   0.36b       Stop    back    incor   0.33b       Stop    front   X       0.14b       Stop    back    X       0.39f       Fric    front   NA      0.27f       Fric    back    NA      0.23f       Fric    front   cor     0.19f       Fric    back    cor     0.40f       Fric    front   incor   0.13f       Fric    back    incor   0.32f       Fric    front   X       0.08f       Fric    back    X       0.13v       Fric    front   NA      0.24v       Fric    back    NA      0.18v       Fric    front   cor     0.17v       Fric    back    cor     0.11v       Fric    front   incor   0.25v       Fric    back    incor   0.16v       Fric    front   X       0.09v       Fric    back    X       0.16

So in total I should get something similar to the grouped data that I have below:

                         Front                              BackpNA pcor pincor cX bNA bcor bincor bX pNA pcor pincor cX bNA bcor bincor bX         p                    b                    p                    b fNA fcor fincor fX vNA vcor vincor vX fNA fcor fincor fX vNA vcor vincor vX         f                    v                    f                    v

I can do some basic filtering of data, and factoring to get certain orders and I know facet_grid(~Vfront) gives me different columns according to Vfront values (based on my data) but the divisions I am asking about is beyond my current R abilities.


Viewing all articles
Browse latest Browse all 11751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>