[R] Matrix barplot

Andreas Tille tillea at rki.de
Fri Jul 25 14:13:44 CEST 2008


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



More information about the R-help mailing list