3 Answers. Sorted by: 2. We can use grepl with sprintf from base R. Split the dataset at - with read.table, use sprintf to join back into a single string specifying the fmt for adding the leading zeros, create the condition in ifelse to return that new format when there is - or ...
adding regression line per group with ggplot2I'm not quite sure whether that's what you want, but have you tried the following?