Given some data:
test <- data.frame(strings = c('a;b;c;;;;;;;', 'd;e;f;g;h;i;j;k;l;m', 'n;o;p;q;r;;;;;', ';;;;;;;;;' ))
How do I remove all trailing semicolons to get:
test <- data.frame(strings = c('a;b;c', 'd;e;f;g;h;i;j;k;l;m', 'n;o;p;q;r', '' ))
Features of this dataframe:
- maximum of 9 semicolons per row, separating a maximum of 10 characters
- rows contain differing amounts of characters, and the semicolons always add to 9
- when a row contains no characters, it contains 9 semicolons.