I am using a segmented line plot and want to group variables on the y-axis based on a factor (in this case Patient ID). How can I change the width of the ticks on the y so that a patient is grouped by his/her ID, and only one label is given for each unique ID?
An example of my data and plot is below.
ggplot(data) +
geom_segment(aes(x=age1, xend=age2,
y=PatientID, yend=PatientID, colour=mortality)) +
scale_colour_manual(values=c("green", "red", "black"))
Data:
PatientID age1 age2 mortality
11313 0 30 low
11313 31 50 low
11313 51 65 med
11313 0 10 med
11313 0 50 hi
131NY 0 30 med
143CA 24 27 hi
165099 23 45 med
165099 46 55 hi
165099 40 55 med