f_replace: Replace Characters in Strings

Description Usage Arguments Value See Also Examples

Description

A wrapper for gsub for replacing substrings that is useful for ggplot2 scales. Useful for taking field names like 'Cool_Variable' and turning it into 'Cool Variable'.

Usage

1
2
3
f_replace(x, pattern = "_", replacement = " ", ...)

ff_replace(...)

Arguments

x

A vector of text strings.

pattern

A character string defining search patterns.

replacement

A character string defining replacement patterns.

...

Other arguments passed to gsub.

Value

Returns a string vector with characters replaced.

See Also

strwrap

Examples

1
2
3
4
5
f_replace('Cool_Variable')
f_title(f_replace('cool_variable'))
f_replace('Cool_Variable', pattern = '([A-Z])', replacement = '\\L\\1')
cat(f_replace('really long label names are the pits',
    pattern = '\\s', replace = '\n'))

numform documentation built on Oct. 10, 2021, 1:10 a.m.