[R] is it possible to combine multiple barplots?
Titus von der Malsburg
malsburg at gmail.com
Tue Jun 9 16:39:30 CEST 2009
You can use barchart in package lattice. Here's a rough sketch:
library(lattice)
dataA <- rep(1:4, c(3,2,2,4))
dataB <- rep(1:4, c(5,4,3,2))
da <- data.frame(table(dataA))
db <- data.frame(table(dataB))
da$cond <- "a"
db$cond <- "b"
colnames(da)[1] <- "data"
colnames(db)[1] <- "data"
d <- rbind(da, db)
barchart(Freq~data|cond, d)
Titus
On Tue, Jun 09, 2009 at 04:23:32PM +0200, Philipp Schmidt wrote:
> i am working with two sets of likert scale type (4 distinct values) data:
>
> dataA <- rep(1:4, c(3,2,2,4))
> dataB <- rep(1:4, c(5,4,3,2))
>
> i can now (bar)plot both of these separately and compare the distributions.
>
> plot(table(dataA), type='h')
> plot(table(dataB), type='h')
>
> is there a way to plot both of them in one plot, so that the bars for
> value "1" (dataA: 3, dataB: 5) would appear side by side, followed by
> the bars for value 2 etc.?
>
> thanks!
>
> best - P
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list