Learn R Programming

numform (version 0.6.4)

f_replace: 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

Run this code
# NOT RUN {
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'))
# }

Run the code above in your browser using DataLab