Learn R Programming

fgeo.plot (version 1.1.11)

suffix_match: Suffix a strings where a vector exactly matches one specific string.

Description

Suffix a strings where a vector exactly matches one specific string.

Usage

suffix_match(string, to_match, .match, suffix)

Value

A modified version of x.

Arguments

string

A vector of strings to suffix.

to_match

A vector of strings to match with .match.

.match

A string to match the vector to_match with.

suffix

A suffix to add at the end of each element of string.

Examples

Run this code
suffix_match(
  string = c("one", "banana"),
  to_match = c("number", "fruit"),
  .match = "number",
  suffix = "_num"
)

suffix_match(
  string = c("tag1", "tag2"),
  to_match = c("dead", "not-dead"),
  .match = "dead",
  suffix = ".d"
)

vft <- data.frame(
  Tag = c("01", "02"),
  Status = c("dead", "alive"),
  stringsAsFactors = FALSE
)
transform(vft, tagged = suffix_match(Tag, Status, "dead", ".d"))

Run the code above in your browser using DataLab