On Mon, Sep 12, 2011 at 8:54 PM, Mikkel Grum <mi2kelg...@yahoo.com> wrote:
> I've created a chart with times that employees have entered data on named 
> tasks as in the following example:
>
> Employee <- c(rep("Tom", 127),
> rep("Dick", 121),
> rep("Sally", 130)
> )
> Time <- c(seq(as.POSIXct("2011-09-12 07:00:00"), as.POSIXct("2011-09-12 
> 14:00:00"), 200),
> seq(as.POSIXct("2011-09-12 07:00:00"), as.POSIXct("2011-09-12 14:00:00"), 
> 210),
> seq(as.POSIXct("2011-09-12 07:05:00"), as.POSIXct("2011-09-12 13:55:00"), 190)
> )
> Task <- c(rep("Task A", 56), rep("Task B", 27), rep("Task C", 44),
> rep("Task A", 22), rep("Task D", 99),
> rep("Task B", 44), rep("Task E", 26), rep("Task F", 38), rep("Task G", 22)
> )
> Schedule <- data.frame(Employee, Time, Task)
>
> require(lattice)
> ticks = seq(as.POSIXct("2011-09-12 06:30:00"),
>     as.POSIXct("2011-09-12 14:30:00"), by = '30 min')
> marks = c("", "07:00", "", "08:00", "", "09:00", "",
>     "10:00", "", "11:00", "", "12:00", "", "13:00", "", "14:00", "")
> dotplot(Employee ~ Time, group = Task, data = Schedule, xlab = "",
>     horizontal = TRUE, scales = list(x = list(at = ticks, labels = marks, cex 
> = 0.4), cex = 0.5), cex = 0.5)
>
> I would like to label the tasks in the chart, i.e. have a left aligned label 
> above each new task. This would mean plotting the data from
>
> aggregate(Schedule$Time, by = list(Schedule$Employee, Schedule$Task), min)
>
> How do I do this? A legend becomes unwieldy when there are many tasks and 
> employees.
> Any help would greatly be appreciated.

You can try the directlabels package. A first approximation might be

require(directlabels)
p <- dotplot(...)
direct.label(p, "top.qp")

-Deepayan

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to