Package 'stringfix'

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

Help Index


paste ', ' in the way of pipe operator

Description

paste ', ' in the way of pipe operator

Usage

a % % b

a %,% b

Arguments

x

A string (or coerced to)

y

A string (or coerced to)

Details

This functions is a pipe version of paste

Value

The concatenation of x and y strings

Examples

'Hello' % % 'world'
'Your pastas taste like' % % '%>%'
'Hello' %,% 'world...'
'Your pastas taste like ' %+% '%>%...' %,% 'or %>>%...'

paste0 in the way of pipe operator

Description

paste0 in the way of pipe operator

Usage

a %+% b

Arguments

x

A string (or coerced to)

y

A string (or coerced to)

Details

This functions is a pipe version of paste0

Value

The concatenation of x and y strings

Examples

'Hello ' %+% 'world'
'Your pastas taste like ' %+% '%>%'
'coco' %+% 'bolo'

Collapse a character vector to a character string

Description

Collapse a character vector to a character string

Usage

x %c% y

Arguments

x

A character vector

y

Character string, collapse parameter of paste0

Details

This function is a pipe version of paste0 with collapse parameter to specify

Value

A character string

Examples

c('N', 'F', 'K', 'A') %c% ' '
'All I wanna do' %e% '' %c% ''

count pattern in strings the way of pipe operator

Description

count pattern in strings the way of pipe operator

Usage

x %count% y

Arguments

x

Pattern to count in string

y

string where to count pattern

Details

This functions is a pipe version of stringr::count

Value

A vector of integer

Examples

fruit <- c("apple", "banana", "pear", "pineapple")
"a" %count% fruit
c("a", "b", "p", "p") %count% fruit

Explode a character string

Description

Explode a character string

Usage

x %e% p

Arguments

x

A character string

p

A pattern

Details

This function is a pipe version of stringr::str_split for a character string, with simplify = TRUE

Value

a character vector

Examples

'The little horse under the weather' %e% ' '
'The little horse under the weather' %e% ''

Explode a character vector

Description

Explode a character vector

Usage

x %ee% p

Arguments

x

A character vector

p

A pattern

Details

This function is a pipe version of stringr::str_split for a character vector, with simplify = TRUE

Value

a tibble

Examples

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)

Description

grepl in the way of pipe operator (case sensitive)

Usage

x %g% y

Arguments

x

string where to search pattern with grepl

y

pattern submitted to grepl

Details

This functions is a pipe version of grepl

Value

A boolean

Examples

'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)

Description

grepl in the way of pipe operator (ignore case)

Usage

x %gic% y

Arguments

x

string where to search pattern with grepl

y

pattern submitted to grepl

Details

This functions is a pipe version of grepl with ignore.case = TRUE

Value

A boolean

Examples

'pig' %gic% 'The pig is in the cornfield'
'PIG' %gic% 'The PiG is in the cornfield'

Left pad strings the way of pipe operator

Description

Left pad strings the way of pipe operator

Usage

string %lpad% pad.width

Arguments

string

Character vector or NULL

pad.width

string or .digit where to indicate the pad and widht

Details

This functions is a pipe version of stringr::pad

Value

A character vector or NULL

Examples

5 %lpad% '0.5'
5 %lpad%   .5
5 %lpad%  '.5'
5 %lpad% '2.5'
'é' %lpad% 'é.5'

negation of in infix operator

Description

negation of in infix operator

Usage

a %out% b

Arguments

a

Vector or NULL, values to be matched

b

Vector or NULL, values to be matched

Details

This function comes from https://github.com/pierucci/rmngb/tree/master/rmngb

Value

a boolean

Examples

'coca' %out% c('cola')
'coca' %out% c('coca', 'cola')

Both side pad strings the way of pipe operator

Description

Both side pad strings the way of pipe operator

Usage

string %pad% pad.width

Arguments

string

Character vector or NULL

pad.width

string or .digit where to indicate the pad and width

Details

This functions is a pipe version of stringr::pad

Value

A character vector or NULL

Examples

5 %pad% '.3'
5 %rpad% '0.3'

Replace matched patterns in a string

Description

Replace matched patterns in a string

Usage

x %re% y.z

Arguments

x

A character vector

y.z

A vector of two string specifying pattern for match and replace

Details

This function is a pipe version of stringr::str_replace

Value

A character vector

Examples

'totoro12_13' %re% c('[0-9]+', 'to')

Replace matched patterns in a string

Description

Replace matched patterns in a string

Usage

x %reall% y.z

Arguments

x

A character vector

y.z

A vector of two string specifying pattern for match and replace

Details

This function is a pipe version of stringr::str_replace_all

Value

A character vector

Examples

'totoro12_13' %reall% c('[0-9]+', 'to')

Remove matched patterns in a string

Description

Remove matched patterns in a string

Usage

x %rm% y

Arguments

x

A character vector

y

Character string or pattern to remove

Details

This function is a pipe version of stringr::str_remove

Value

A character vector

Examples

'totoro' %rm% 'to'

Remove matched patterns in a string

Description

Remove matched patterns in a string

Usage

x %rmall% y

Arguments

x

A character vector

y

Character string or pattern to remove

Details

This function is a pipe version of stringr::str_remove_all

Value

A character vector

Examples

'totoro' %rmall% 'to'

Right pad strings the way of pipe operator

Description

Right pad strings the way of pipe operator

Usage

string %rpad% pad.width

Arguments

string

Character vector or NULL

pad.width

string or .digit where to indicate the pad and width

Details

This functions is a pipe version of stringr::pad

Value

A character vector or NULL

Examples

5 %rpad% '.2'
'é' %rpad% 'è.5'

substring in the way of pipe operator

Description

substring in the way of pipe operator

Usage

x %s% yz

Arguments

x

Vector or NULL, values to be substringed

y.z

A character or 0.digit to call substr

Details

This functions is a pipe version of substr

Value

A string or NULL

Examples

'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

Description

Run transcoder shiny app

Usage

run_transcoder(
  launch.browser = getOption("shiny.launch.browser", interactive())
)

Make names of a tibble tolower

Description

Make names of a tibble tolower

Usage

tolower_names(d)

Arguments

d

tibble

Value

A tibble

Examples

library(magrittr)
iris %>% tolower_names %>% head

Make names of a tibble toupper

Description

Make names of a tibble toupper

Usage

toupper_names(d)

Arguments

d

tibble

Value

A tibble

Examples

library(magrittr)
iris %>% toupper_names %>% head