On Tue, 27 Nov 2001, Winifred Lambert wrote:
> All,
>
> This should be a simple one. I know I've done this before but for the
> life of me can't remember how to do it and can't find any examples in
> the email - although I know I've seen some recently and probably deleted
> them because I didn't want my mailbox cluttered with emails explaining
> something I already knew how to do!
>
> I used table() on a large dataframe containing wind directions by time
> of day over a very long time period to determine the number of
> occurrences (NUM) of specific wind directions (DIR) during the hours of
> the day (HOUR). It produces a nice table/matrix with the hours as the
> column names and the directions as the row names, but I need to have it
> in a different format in order to make contour plots and do other
> manipulations. What I need is a dataframe or matrix in the format
>
> DIR HOUR NUM
> 0 0 6
> 0 1 7
> 0 2 3
> 0 3 10
> . . .
> . . .
> 0 23 8
> 1 0 2
> 1 1 19
> 1 2 14
> 1 3 3
> . . .
>
> and so on. The length of unique values for DIR is 361 (0-360) and the
> length of unique values for Hour is 24 (0-23). Sorry for such a simple
> question - I must be having a brain-blip.
Looks like you need mat2tr in library MASS.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
|