Adair, Laurence <Laurence.Adair <at> parsons.com> writes: > 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??
In the example below the first three lines create a random test data frame with columns date and id. The fourth line calculates the counts using table, converts it back to a data frame (which has the effect of adding a Freq column) and removes any row with a Freq of 0. The last two lines load package gregmisc and then plot the data using balloonplot from that package. set.seed(1) r <- 100 + sample(5, 25, replace = TRUE) DF <- data.frame(date = structure(rev(r), class = "Date"), id = r) DF2 <- subset(as.data.frame(table(DF)),Freq > 0) require(gregmisc) with(DF2, balloonplot(date, id, Freq)) ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
