Description
Suppose I have a data frame where a column contains information that I would like to separate, but only some of the rows have the second part. Would it make sense to have an option to fill the empty cells with NAs?
My use case is college football rankings tables. In the teams column they also list the first place votes, if any, which I want saved as its own column. Right now I'm using stringr + regex to extract the votes, set the ones without votes to NA or zero, and then scrub the numeric information from the teams column.
Could this potentially be improved with separate? Something like,
separate(col, into = c("col1", "col2"), sep = ",", extra = "fill") or fill = TRUE, or fill = "value"
?
My thought would be for each row, if delimiter exists, then split, otherwise col stays in col1 and col2 would be filled with NA or the desired value.
Thoughts?