replace_pattern: Replace pattern everywhere in a data.frame

Description Usage Arguments Value Examples

View source: R/replace_pattern.R

Description

Replace pattern everywhere in a data.frame

Usage

1
replace_pattern(dataset, pattern, replacement, exact = FALSE)

Arguments

dataset

a data.frame

pattern

Pattern to look for.

replacement

A character of replacements.

exact

a boolean if TRUE the whole value need ton match

Value

a data.frame

Examples

1
2
3
4
5
6
library(dplyr)
library(tidyr)
dataset <-
data.frame(a=as.factor(letters)[1:7],b=letters[1:7],c=1:7,stringsAsFactors = FALSE) %>%
unite("fus",a,b,remove=FALSE,sep="")
dataset %>% replace_pattern("a",'"XXX') %>% summary()

ThinkR-open/ThinkR documentation built on July 4, 2018, 12:17 p.m.