I figured this out while posting the question :)
The trick is that within the functions specified as arguments to the summarize
function, you refer to them as a bareword; Assignments$Assignee
should be called just Assignee
, no data frame, no quotes, etc.
So once I had figured out that the rle
function could get me where I needed to be, I had what I needed.
ddply(Assignments, 'Task',
summarize,
Assignee.Count=length(Assignee),
Unique.Assignees.Involved=length(unique(Assignee)),
Assignments=paste(rle(as.vector(sort(Assignee)))$values,
rle(as.vector(sort(Assignee)))$lengths,
sep=" ", collapse=", "))
Gives:
Task Assignee.Count Unique.Assignees.Involved Assignments
1 1 3 2 Alice 2, Bob 1
2 2 3 3 Alice 1, Bob 1, Chuck 1
3 3 1 1 Alice 1