Morning Community,
I was learning how to use stripchart()
in R as well as the abline()
function to draw arbitrary lines in the graph. I was able to draw horizontal lines when I was grouping with one variable, but was unsuccessful with two or more.
My data:
Group Subgroup Measure
A 1 0.234213
A 1 0.046248
A 1 0.391376
A 2 0.911849
A 2 0.729955
A 2 0.99111
A 2 0.378422
A 3 0.898037
A 3 0.258884
A 3
A 3 0.057631
A 3 0.745202
A 3 0.121376
B 1 0.385198
B 1 0.484399
B 1 0.115034
B 1 0.073629
B 1 0.45615
B 2 0.336108
B 2 0.845458
B 2 0.267494
B 3 0.536123
B 3 1.331731
B 3 0.505114
B 3 0.843348
B 3 0.827932
B 3 0.813351
C 1 0.095587
C 1 0.158822
C 1 0.392376
C 1 0.284625
C 2 0.898819
C 2 0.743428
C 2 0.298989
C 2 0.423961
C 3 0.868351
C 3 0.181547
C 3 1.146131
C 3 0.234941
My code:
stripchart(Measure~Group*Subgroup,data=mydata,method="jitter",pch=19,jitter=0.1,col="black")
abline(h=mydata$Group)
My Assessment:
Wouldn't the abline()
code apply the line to all Y-variables that has the category 'Group'? Or is it that I need to generate a new vector that combines Group and Subgroup? I have tried abline(h=mydata$Group*mydata$Subgroup)
but this gives me the following error:
Warning message:
In Ops.factor(mydata$Group, mydata$Subgroup) :
‘*’ not meaningful for factors
In Hindsight, this wasn't going to work becuase the documentation for abline() does not allow functions. However, when I tried adding abline(h=mydata$Subgroup)
The lines did not work either.