Tutorial by Examples

If you want to change the order of a character strings you can use parentheses in the pattern to group parts of the string together. These groups can in the replacement argument be addresed using consecutive numbers. The following example shows how you can reorder a vector of names of the form &quo...
Let's say we want to eliminate duplicated subsequence element from a string (it can be more than one). For example: 2,14,14,14,19 and convert it into: 2,14,19 Using gsub, we can achieve it: gsub("(\\d+)(,\\1)+","\\1", "2,14,14,14,19") [1] "2,14,19" ...

Page 1 of 1