sublast | R Documentation |
Substitute last occurrence of a pattern in a string
sublast(pattern, replacement, x, ...)
pattern |
character string containing a regular expression whose whose last match in 'x' will be replaced |
replacement |
character string that is a replacement for the matched 'pattern' in 'x' |
x |
a character vector where matches are sought. |
... |
arguments passed to |
string <- 'a_b_c_D'
sublast('_','__',string)
dd <- data.frame(id = 1:3, X_a_1 = 1:3, X_a_2 = 1:3, X_b_1 = 1:3, X_b_2 = 1:3)
dd
names(dd) <- sublast('_','__',names(dd))
tolong(dd, sep = '__')
tolong(dd, sep = '__') %>% tolong(sep = '_', idvar = 'id2', timevar = 'time2')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.