I have a very simple dataset with two variables.
data <- data.frame(
ID = c("A","A","B","C","D","D"),
Service = c("Shop","Online","Shop","Online","Online","Shop"))
I want to use the spread() function on Service, but rather than spread by ID, I want the resulting table to include a "Y" symbol to indicate that ID operates that specific service. For example:
ID Shop Online
A Y Y
B Y -
C - Y
D Y Y
However, the spread() function won't work by just giving a key, so is there a way I can do this using the existing spread function or do I have to use something different?