Re: [R] Matrix barplot

From: Andreas Tille <tillea_at_rki.de>
Date: Fri, 25 Jul 2008 21:29:10 +0200 (CEST)

On Fri, 25 Jul 2008, Nutter, Benjamin wrote:

>> data <- data.frame(Year=c(2000,2001,2002),
> A=c(4,2,1),
> B=c(3,1,2),
> C=c(0,3,5))
>
>> data.mat <- as.matrix(data)[,2:4]
>> rownames(data.mat) <- data$Year
>> data.mat <- t(data.mat)
>> barplot(data.mat,beside=TRUE)

As I said this works great - but now I would like to use the table heading as legend - and have no idea how to access the header (see below)
>
> -----Original Message-----
> On Behalf Of Andreas Tille
> Sent: Friday, July 25, 2008 8:14 AM
> To: r-help_at_r-project.org
> Subject: [R] Matrix barplot
>
> Year A B C
> 2000 4 3 0
> 2001 2 1 3
> 2002 1 2 5

What do I need to specify as legend.text in the barplot command to get A / B / C in the legend if I read the file using

      data <- read.table(file='data.dat', sep = '\t', fill=TRUE, header=TRUE ) Kind regards

       Andreas.

-- 
http://fam-tille.de

______________________________________________
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 - 19:35:05 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 - 20:34:15 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