Learn R Programming

mikropml (version 1.6.1)

replace_spaces: Replace spaces in all elements of a character vector with underscores

Description

Replace spaces in all elements of a character vector with underscores

Usage

replace_spaces(x, new_char = "_")

Value

character vector with all spaces replaced with new_char

Arguments

x

a character vector

new_char

the character to replace spaces (default: _)

Author

Kelly Sovacool, sovacool@umich.edu

Examples

Run this code
dat <- data.frame(
  dx = c("outcome 1", "outcome 2", "outcome 1"),
  a = 1:3, b = c(5, 7, 1)
)
dat$dx <- replace_spaces(dat$dx)
dat

Run the code above in your browser using DataLab