[R] Matrix barplot

From: Andreas Tille <tillea_at_rki.de>
Date: Fri, 25 Jul 2008 14:13:44 +0200 (CEST)


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).

My problem is that if I read the table using

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

everything looks is read as expected if I try

    data

but I have no idea how to separate the Matrix (A B C) to specify the height parameter of barplot as a matrix and the names.arg parameter for the inscription. Whatever I tried I get

    'height' must be a vector or a matrix

and I have no idea to do this right. So I think I'm just facing a data conversion problem and have to turn data[['Year']] into a vector and the remaining table into a matrix.

I guess this is a really simple question - but I failed to find a solution.

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 - 12:15:43 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 - 14:32:31 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