[R] data shape

Tom Sgouros tomfool at as220.org
Thu Dec 20 15:06:34 CET 2007


I have been give a spreadsheet to work with formed as one big table.
What it consists of is a 10-row-by-40-column table for each of about 70
different locations.  In other words, the table row names are repeated
70 times, once for each of the locations (whose names also appear in the
same column, where it's talking about the totals for that location), e.g.:
            A    B    C
 Location1 15   73  123   <-  this row is the sum of the following 3
 Under 10   6   42   23
 10 - 25    4   15   23
 Over 25    5   16   77
 Location2 18   75  113   <- same here
 Under 10   7   45   13
 10 - 25    5   18   44
 Over 25    6   12   56

I want to get this into R as a collection of data frames, one for each
of my locations.  My questions:

  1. There is a way to handle a collection of data frames, isn't there?
     No doubt there are plenty, but what's the easiest way, so that I
     can address them collectively, allowing me to ask such questions as
     what's the max of the over 25's in column C?

  2. What's the easiest way to read such a data array from a text file?
     I can do some editing of a csv file produced from the spreadsheet,
     but don't really know what to aim for.

  3. Is there some shortcut that would allow me to read this directly
     from a spreadsheet?

Many thanks,


 tomfool at as220 dot org

More information about the R-help mailing list