Re: [R] Matrix barplot

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Fri, 25 Jul 2008 22:47:46 +1000

On Fri, 2008-07-25 at 14:13 +0200, Andreas Tille wrote:
> Hi,
>
> as a bloody R beginner I failed to solve the probably simple problem
> to create a barplot of the following data read from a file
>
> Year A B C
> 2000 4 3 0
> 2001 2 1 3
> 2002 1 2 5
>
> The Barplot should look like
>
> 5 | C
> 4 | A C
> 3 | AB C C
> 2 | AB A C BC
> 1 | AB ABC ABC
> +------------------
> 2000 2001 2002
>
> (well, something like that - the colors are encoded as letters in this
> ASCII-graphics - assume the coloring / shading as usual).
>
Hi Andreas,
Try this (assume your data frame is named "atdat"):

library(plotrix)
# barp groups data in columns, not rows, so transpose barp(t(atdat[,2:4]),names.arg=atdat[,1],col=2:4)

Jim



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. Received on Fri 25 Jul 2008 - 12:49:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jul 2008 - 18:32:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive