I am trying to compare values in condition x vs y. Here is my data:
mydata <- structure(list(
Row.names = c("ASPTAm", "ATPtmB_MitoCore", "CI_MitoCore",
"CIII_MitoCore", "CIV_MitoCore", "CO2t", "CO2tm", "CV_MitoCore",
"H2Ot", "H2Otm", "MDH", "MDHm", "O2t", "O2tm", "OF_ATP_MitoCore",
"PGK", "PGM", "PIt2mB_MitoCore", "SUCOASm"),
mean_x = c(-1.416333333,
26.1376024, 8.444222444, 9.983111555, 4.991555778, -5.06, -5.055,
24.43926907, -4.719, -30.9051024, -1.580333333, 3.093666667,
5, 5, 29.7476024, -1.81, -1.81, 25.9436024, -1.698333333),
mean_y = c(-2.455e-14,
78.68825722, 51.30062794, 9.897398744, 4.948699372, -40.05114286,
-40.15114286, 68.14247151, -29.51685714, -108.3586144, -60.164,
10.90278571, 5, 5, 82.39825722, -1.81, -1.81, 86.41154294, -10.58878571
)),
class = "data.frame", row.names = c(NA, -19L),
.Names = c("Row.names", "mean_x", "mean_y"))
I want a point graph with a line connecting between each group. Here is what I tried:
library(reshape2)
library(ggplot2)
mydata <- melt(mydata)
ggplot(mydata, aes(x = Row.names, y = value, color = variable)) +
geom_point(stat = 'identity', position = position_dodge(width = 1.0), size = 2.5) +
theme(axis.text.x = element_text(angle = 60, hjust = 1))
This is the plot I get:
I also want to connect the two points in each variable.
If I group the data by Row.names and then add geom_line()
, it works but the points in each group overlap again.
How do I separate the points while connecting them?