After I split the lines and separate them with a semicolon, I would like to remove the semicolons in front and back of my line. A few semicolons represent spaces in a cell. For example, after a crash, an observation might look like this:
I want the cell to look like this:
TX;PA;CA
Here is my collapse code:
new_df <- group_by(old_df, unique_id) %>% summarize_each(funs(paste(., collapse = ';')))
If I try to use gsub for a semicolon, it removes all of them. If, if I remove the end character, it just removes one of the semicolons. Any ideas on how to remove everything at the beginning and end, but leaving those that are between the observations? Thanks.
source share