f_replace {numform}R Documentation

Replace Characters in Strings

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

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

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

[Package numform version 0.7.0 Index]