Re: [R] Counting question

From: Deepayan Sarkar <>
Date: Sat 31 Jul 2004 - 02:31:06 EST

On Friday 30 July 2004 10:13, Adair, Laurence wrote:
> Hi All,
> Here is something that sounds simple, but I'm having trouble getting
> it. I have a data frame with two columns, the first is date and the
> second is employee ID. I'd like to plot date on the horizontal axis,
> employee ID on the vertical axis, and the number of times the
> employee appears for the given date as a color. I've kluged
> something where I make a table (table(date, id)) and add points to a
> plot by looping through the rownames (employee ids) of the table.
> But certainly there is a better way of doing this??, id)) would have been useful, except that it coerces date and id to be factors. To work around that, you could do: <- sort(unique(date)) <- sort(unique(id))
mydf <- = factor(date, levels =,

                            id = factor(id, levels =
mydf <- subset(mydf, Freq > 0)

plot([mydf$date],[mydf$id], col = mydf$Freq)

Hope that helps,

Deepayan mailing list PLEASE do read the posting guide! Received on Sat Jul 31 03:13:39 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:23 EST