novelName: Generate a name with a prefix disjoint from a set of names

View source: R/novelName.R

novelNameR Documentation

Generate a name with a prefix disjoint from a set of names

Description

Generate a name with a prefix disjoint from a set of names

Usage

novelName(prefix, names)

Arguments

prefix

character, desired prefix

names

character list of names to avoid

Value

new name disjoint from set of names

Examples


# basic op
novelName('b', c('a', 'b', 'c'))



# complex application (converting logistic
# links to probabilities).
d <- data.frame(
  exampleId = c(1, 1, 2, 2),
  resultLabel = c('a', 'b' , 'a', 'b'),
  linkValue = c(-5, 2, -2, -1),
  stringsAsFactors = FALSE)

totColName <- novelName('t', colnames(d))

d ->.;
  mutate_se(., c(totColName := "exp(linkValue)")) ->.;
  group_by_se(., "exampleId") ->.;
  mutate_se(., c("probability" :=
                paste0(totColName, '/sum(', totColName, ')'))) ->.;
  deselect(., totColName)


WinVector/seplyr documentation built on Aug. 26, 2022, 12:01 p.m.