2

I have a dataframe with several groups. My data are like this :

Group   Var1    Var2
G1     65,71    72,68
G1     52,67    55,85
G1     73,29    53,73
G1     59,19    53,73
G1     50,62    50,45
G1     44,29    55,17
G1     57,08    54,88
G1     60,4     53,73
G1     80,17    53,73
G1     66,17    53,73
G2     119      121,17
G2     120      119,01
G2     127      131,68
G2     134      141,07
G2     141      141,07
G2     139      140,96
G2     139      141,12
G2     131      141,18
G2     133,7    141,18
G3     94       101,81
G3     95       100,95
G3     94       104,02
G3     104      138,62
G3     125,46   102,89
G3     93       129,5
G3     95       103,81
G3     94       106,48
G3     95,5     104,14
G3     96       138,14
G3     96       104,08

I've already drawn a plot :

qplot(Var2, Var1, data = graph, colour = Group)+geom_point(size=2) +geom_line(aes(y = Var2, colour = "Group", size=0.5))

My plot: enter image description here

My first idea was to to have everything on the same graph...

But I would like to have 1 line (of different colour) for each subsample , ie if I have 2 groups : I want to have 2 straight lines, if I have 4 different groups I want to have 4 straight lines on my graph...

zx8754
  • 52,746
  • 12
  • 114
  • 209
Auré
  • 161
  • 1
  • 11
  • Somethings [like this](http://stackoverflow.com/questions/12281335/adding-regression-line-per-group-with-ggplot2)? – aosmith Jul 18 '16 at 14:39
  • Here we have several lines which is a good thing. But I don't want a regression line, I want to obtain for each group a line y=Var2 to compare this line with the points for each group. I want "to keep" VAR2 values ... – Auré Jul 18 '16 at 15:09

1 Answers1

0

I've found my answer. On my graph it's already the case : because I want to add a line : x=VAR2 and y=VAR2 . As a consequence, my line will always have the same shape and be at the same place : (0,0)... (100,100) ... whatever the value of Var2 .

Auré
  • 161
  • 1
  • 11