Learn R Programming

seplyr (version 1.0.4)

novelName: 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

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab