I'm trying to group two barcharts, but I haven't been successful so far... I followed this example, but the output is not as desired. The bars are one behind the other instead of next to each other.
Here's the line of code I use:
barplot(as.matrix(counts),xaxt='n', col=c("white","blue"), ylim=c(0.1,1300), axes=FALSE, beside=T, space = 1.4, mar=c(5,5,5,5))
When I try this...
> barplot(as.matrix(counts), beside = TRUE)
> barplot(as.matrix(counts), beside = TRUE, space = c(0, 1.4))
... I get this plot:
And this is my data frame, in case that causes the problem:
> counts
V1 V2
1 26 50
2 50 86
3 86 50
4 50 50
5 50 50
6 50 100
7 100 150
8 150 350
9 350 50
10 50 28
11 28 300
12 300 250
13 250 300
14 300 250
15 250 300
16 300 500
17 500 400
18 400 0
19 600 0
20 500 0
21 1250 0
> dput(counts)
structure(list(V1 = c(26, 50, 86, 50, 50, 50, 100, 150, 350,
50, 28, 300, 250, 300, 250, 300, 500, 400, 600, 500, 1250), V2 = c(50,
86, 50, 50, 50, 100, 150, 350, 50, 28, 300, 250, 300, 250, 300,
500, 400, 0, 0, 0, 0)), .Names = c("V1", "V2"), row.names = c(NA,
-21L), class = "data.frame")
Any ideas?