Reputation: 12152
This is hard to describe in words. First the picture.
It was created with that code
df <- data.frame(a=sample(1:2, 60, replace=TRUE), b=c(1:3))
stripchart(b~a, data=df, method="stack", offset=0.5, pch=20)
Please look at the value bottom left (1
x1.0
). There are 13 points. I want to group them by (e.g.) 5 points. It means I want columns of 5 points. The result should be like that.
Upvotes: 0
Views: 212
Reputation: 37641
Using your data generation function, but with different results because of different random selections.
df <- data.frame(a=sample(1:2, 60, replace=TRUE), b=c(1:3))
stripchart(b~a, data=df, method="stack", offset=0.5, pch=20)
df2 = df ## So that df is not changed
for(A in unique(df$a)) {
for(B in unique(df$b)) {
S = which(df$a==A & df$b==B)
while(length(S) > 5) {
S = S[-(1:5)]
df2$b[S] = df2$b[S]+0.05
}
}
}
stripchart(b~a, data=df2, method="stack", offset=0.5, pch=20)
Upvotes: 2