valueConvertGrep: A function replacing mutiple values from a vector, but using...

Description Usage Arguments Value Examples

View source: R/stringmanipulation.R

Description

A function replacing mutiple values from a vector, but using grep. Thus, patterns can be part of the values, or any other pattern grep understands.

Usage

1
valueConvertGrep(valueData, patterns, replacements, other = NA)

Arguments

valueData

Input

patterns

A vector containing which values should be replaced

replacements

A vector containing replacement values

other

Any vales which is not found in 'patterns' is set to this. Defaults to NA

Value

a vector with the replaced values

Examples

1
2
3
4
5
6
origin = c("gleason 3+3", "gleason 3+3=6", "gleason 3+3", "gleason 4+3=7", "gleason 3+4=7", "gleason 3+3", "gleason 7")
patternVector = c("3[+]3", "4[+]3", "3[+]4")
replacementVector = c("1", "3", "2")
valueConvert(origin, patternVector, replacementVector, "unknown")

#returns "1", "1", "1", "3", "2", "1", "unknown"

jacobfredsoee/LCEF documentation built on Feb. 7, 2021, 8:10 p.m.