stringfix : infix operators for strings manipulations
install.packages("stringfix", repos = c('https://guillaumepressiat.r-universe.dev', 'https://cloud.r-project.org'))
Some infix operators and other functions to make syntax more left to right.
"In a manner of coding, I just want to say..." % % "Nothing."
Examples
paste
'Hello ' %+% 'world'
'Your pastas taste like ' %+% '%>%'
'coco' %+% 'bolo'
'Hello' % % 'world'
'Your pastas taste like' % % '%>%'
'Hello' %,% 'world...'
'Your pastas taste like ' %+% '%>%...' %,% 'or %>>%...'
grepl
Case sensitive
'pig' %g% 'The pig is in the cornfield'
'Pig' %g% 'The pig is in the cornfield'
Case insensitive (ignore.case)
'pig' %gic% 'The pig is in the cornfield'
'PIG' %gic% 'The PiG is in the cornfield'
substring
'NFKA008' %s% '1.4'
'NFKA008' %s% .4
'where is' % % ('the pig is in the cornfield' %s% '1.7') %+% '?'
count
fruit <- c("apple", "banana", "pear", "pineapple")
"a" %count% fruit
c("a", "b", "p", "p") %count% fruit
pad, lpad and rpad
5 %lpad% '0.5'
5 %lpad% .5
5 %lpad% '.5'
5 %lpad% '2.5'
'é' %lpad% 'é.5'
names of tibbles : tolower and toupper
library(magrittr)
iris %>% toupper_names %>% head