pik-piam / quitte

Bits and pieces of code to use with quitte-style data frames
0 stars 10 forks source link

extend strtrimcommon() to trim on marker characters #66

Closed 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q closed 1 year ago

0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q commented 1 year ago
x <- c('/tmp/remind2_test-convGDX2MIF_fulldata.gdx',
       '/tmp/remind2_test-Ariadne_fulldata.gdx',
       '/tmp/remind2_test-NAVIGATE_fulldata.gdx',
       '/tmp/remind2_test-NGFS_fulldata_oneRegi.gdx',
       '/tmp/remind2_test-SHAPE_fulldata.gdx')

strtrimcommon(x, USE.NAMES = TRUE)
 /tmp/remind2_test-convGDX2MIF_fulldata.gdx      /tmp/remind2_test-Ariadne_fulldata.gdx 
                     "convGDX2MIF_fulldata"                          "Ariadne_fulldata" 
    /tmp/remind2_test-NAVIGATE_fulldata.gdx /tmp/remind2_test-NGFS_fulldata_oneRegi.gdx 
                        "NAVIGATE_fulldata"                     "NGFS_fulldata_oneRegi" 
       /tmp/remind2_test-SHAPE_fulldata.gdx 
                           "SHAPE_fulldata" 
x <- c('Some|name|with|common|text|elements',
       'Some|name|without|extra|text|elements')

strtrimcommon(x, split = '|', return.all = TRUE)
$left
[1] "Some|name"

$strings
[1] "with|common"   "without|extra"

$right
[1] "text|elements"
[Package quitte version 0.3119.0 [Index](http://127.0.0.1:36245/help/library/quitte/html/00Index.html)]