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

Description Usage Arguments Value Examples

View source: R/novelName.R

Description

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

Usage

1
novelName(prefix, names)

Arguments

prefix

character, desired prefix

names

character list of names to avoid

Value

new name disjoint from set of names

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 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)

seplyr documentation built on Sept. 5, 2021, 5:12 p.m.