Title: | Strings manipulations in a piping way of coding |
---|---|
Description: | Some infix operators and other utility functions to make syntax more and more left to right. In a manner of coding, I just want to say %>% nothing. |
Authors: | Guillaume Pressiat |
Maintainer: | Guillaume Pressiat <[email protected]> |
License: | GPL-2 |
Version: | 0.1.0 |
Built: | 2025-01-22 02:39:45 UTC |
Source: | https://github.com/GuillaumePressiat/stringfix |
paste ', ' in the way of pipe operator
a % % b a %,% b
a % % b a %,% b
x |
A string (or coerced to) |
y |
A string (or coerced to) |
This functions is a pipe version of paste
The concatenation of x
and y
strings
'Hello' % % 'world' 'Your pastas taste like' % % '%>%' 'Hello' %,% 'world...' 'Your pastas taste like ' %+% '%>%...' %,% 'or %>>%...'
'Hello' % % 'world' 'Your pastas taste like' % % '%>%' 'Hello' %,% 'world...' 'Your pastas taste like ' %+% '%>%...' %,% 'or %>>%...'
paste0 in the way of pipe operator
a %+% b
a %+% b
x |
A string (or coerced to) |
y |
A string (or coerced to) |
This functions is a pipe version of paste0
The concatenation of x
and y
strings
'Hello ' %+% 'world' 'Your pastas taste like ' %+% '%>%' 'coco' %+% 'bolo'
'Hello ' %+% 'world' 'Your pastas taste like ' %+% '%>%' 'coco' %+% 'bolo'
Collapse a character vector to a character string
x %c% y
x %c% y
x |
A character vector |
y |
Character string, collapse parameter of paste0 |
This function is a pipe version of paste0 with collapse parameter to specify
A character string
c('N', 'F', 'K', 'A') %c% ' ' 'All I wanna do' %e% '' %c% ''
c('N', 'F', 'K', 'A') %c% ' ' 'All I wanna do' %e% '' %c% ''
count pattern in strings the way of pipe operator
x %count% y
x %count% y
x |
Pattern to count in string |
y |
string where to count pattern |
This functions is a pipe version of stringr::count
A vector of integer
fruit <- c("apple", "banana", "pear", "pineapple") "a" %count% fruit c("a", "b", "p", "p") %count% fruit
fruit <- c("apple", "banana", "pear", "pineapple") "a" %count% fruit c("a", "b", "p", "p") %count% fruit
Explode a character string
x %e% p
x %e% p
x |
A character string |
p |
A pattern |
This function is a pipe version of stringr::str_split for a character string, with simplify = TRUE
a character vector
'The little horse under the weather' %e% ' ' 'The little horse under the weather' %e% ''
'The little horse under the weather' %e% ' ' 'The little horse under the weather' %e% ''
Explode a character vector
x %ee% p
x %ee% p
x |
A character vector |
p |
A pattern |
This function is a pipe version of stringr::str_split for a character vector, with simplify = TRUE
a tibble
c('The little horse under the weather', "He who gave courage", "It was a little white horse", 'All behind, all behind', "It was time of the little white horse", "All behind him before") %ee% " |'|, "
c('The little horse under the weather', "He who gave courage", "It was a little white horse", 'All behind, all behind', "It was time of the little white horse", "All behind him before") %ee% " |'|, "
grepl in the way of pipe operator (case sensitive)
x %g% y
x %g% y
x |
string where to search pattern with grepl |
y |
pattern submitted to grepl |
This functions is a pipe version of grepl
A boolean
'pig' %g% 'The pig is in the cornfield' 'Pig' %g% 'The pig is in the cornfield'
'pig' %g% 'The pig is in the cornfield' 'Pig' %g% 'The pig is in the cornfield'
grepl in the way of pipe operator (ignore case)
x %gic% y
x %gic% y
x |
string where to search pattern with grepl |
y |
pattern submitted to grepl |
This functions is a pipe version of grepl with ignore.case = TRUE
A boolean
'pig' %gic% 'The pig is in the cornfield' 'PIG' %gic% 'The PiG is in the cornfield'
'pig' %gic% 'The pig is in the cornfield' 'PIG' %gic% 'The PiG is in the cornfield'
Left pad strings the way of pipe operator
string %lpad% pad.width
string %lpad% pad.width
string |
Character vector or NULL |
pad.width |
string or .digit where to indicate the pad and widht |
This functions is a pipe version of stringr::pad
A character vector or NULL
5 %lpad% '0.5' 5 %lpad% .5 5 %lpad% '.5' 5 %lpad% '2.5' 'é' %lpad% 'é.5'
5 %lpad% '0.5' 5 %lpad% .5 5 %lpad% '.5' 5 %lpad% '2.5' 'é' %lpad% 'é.5'
negation of in infix operator
a %out% b
a %out% b
a |
Vector or NULL, values to be matched |
b |
Vector or NULL, values to be matched |
This function comes from https://github.com/pierucci/rmngb/tree/master/rmngb
a boolean
'coca' %out% c('cola') 'coca' %out% c('coca', 'cola')
'coca' %out% c('cola') 'coca' %out% c('coca', 'cola')
Both side pad strings the way of pipe operator
string %pad% pad.width
string %pad% pad.width
string |
Character vector or NULL |
pad.width |
string or .digit where to indicate the pad and width |
This functions is a pipe version of stringr::pad
A character vector or NULL
5 %pad% '.3' 5 %rpad% '0.3'
5 %pad% '.3' 5 %rpad% '0.3'
Replace matched patterns in a string
x %re% y.z
x %re% y.z
x |
A character vector |
y.z |
A vector of two string specifying pattern for match and replace |
This function is a pipe version of stringr::str_replace
A character vector
'totoro12_13' %re% c('[0-9]+', 'to')
'totoro12_13' %re% c('[0-9]+', 'to')
Replace matched patterns in a string
x %reall% y.z
x %reall% y.z
x |
A character vector |
y.z |
A vector of two string specifying pattern for match and replace |
This function is a pipe version of stringr::str_replace_all
A character vector
'totoro12_13' %reall% c('[0-9]+', 'to')
'totoro12_13' %reall% c('[0-9]+', 'to')
Remove matched patterns in a string
x %rm% y
x %rm% y
x |
A character vector |
y |
Character string or pattern to remove |
This function is a pipe version of stringr::str_remove
A character vector
'totoro' %rm% 'to'
'totoro' %rm% 'to'
Remove matched patterns in a string
x %rmall% y
x %rmall% y
x |
A character vector |
y |
Character string or pattern to remove |
This function is a pipe version of stringr::str_remove_all
A character vector
'totoro' %rmall% 'to'
'totoro' %rmall% 'to'
Right pad strings the way of pipe operator
string %rpad% pad.width
string %rpad% pad.width
string |
Character vector or NULL |
pad.width |
string or .digit where to indicate the pad and width |
This functions is a pipe version of stringr::pad
A character vector or NULL
5 %rpad% '.2' 'é' %rpad% 'è.5'
5 %rpad% '.2' 'é' %rpad% 'è.5'
substring in the way of pipe operator
x %s% yz
x %s% yz
x |
Vector or NULL, values to be substringed |
y.z |
A character or 0.digit to call substr |
This functions is a pipe version of substr
A string or NULL
'NFKA008' %s% '1.4' 'NFKA008' %s% .4 'where is' % % ('the pig is in the cornfield' %s% '1.7') %+% '?' 'NFKA008' %s% 5.7
'NFKA008' %s% '1.4' 'NFKA008' %s% .4 'where is' % % ('the pig is in the cornfield' %s% '1.7') %+% '?' 'NFKA008' %s% 5.7
Run transcoder shiny app
run_transcoder( launch.browser = getOption("shiny.launch.browser", interactive()) )
run_transcoder( launch.browser = getOption("shiny.launch.browser", interactive()) )
Make names of a tibble tolower
tolower_names(d)
tolower_names(d)
d |
tibble |
A tibble
library(magrittr) iris %>% tolower_names %>% head
library(magrittr) iris %>% tolower_names %>% head
Make names of a tibble toupper
toupper_names(d)
toupper_names(d)
d |
tibble |
A tibble
library(magrittr) iris %>% toupper_names %>% head
library(magrittr) iris %>% toupper_names %>% head