Package 'noah'

Title: Create Unique Pseudonymous Animal Names
Description: Generate pseudonymous animal names that are delightful and easy to remember like the Likable Leech and the Proud Chickadee. A unique pseudonym can be created for every unique element in a vector or row in a data frame. Pseudonyms can be customized and tracked over time, so that the same input is always assigned the same pseudonym.
Authors: Tobias Busch [aut, cre]
Maintainer: Tobias Busch <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-10-25 05:02:33 UTC
Source: https://github.com/teebusch/noah

Help Index


Add column with pseudonyms to a data frame

Description

Add column with pseudonyms to a data frame

Usage

add_pseudonyms(
  .data,
  ...,
  .name = "pseudonym",
  .before = NULL,
  .after = NULL,
  .ark = NULL
)

Arguments

.data

A data frame to add pseudonyms to.

...

Columns to use as keys on which pseudonyms should be based. Supports tidy select. If empty, all columns will be used.

.name

Name of the new column as string.

.before

<tidy-select> Destination of columns selected by .... Supplying neither will move columns to the left-hand side; specifying both is an error.

.after

<tidy-select> Destination of columns selected by .... Supplying neither will move columns to the left-hand side; specifying both is an error.

.ark

An Ark object. If NULL (default) a new Ark is created. Using an existing Ark makes sure that the same input returns the same pseudonym.

Value

A data frame with an additional column containing the pseudonyms.

Examples

add_pseudonyms(mtcars)

A pseudonym archive

Description

An Ark object can create and remember pseudonyms. Given the same input, it will always return the same pseudonym. No pseudonym will repeat.

Public fields

log

Hashtable for all used pseudonyms. Inputs (keys) are stored as hashes.

Methods

Public methods


Method new()

Create new ark object.

Usage
Ark$new(alliterate = FALSE, parts = NULL, seed = NULL)
Arguments
alliterate

Logical. Should the Ark return alliterations by default?

parts

List of character vectors with name parts to be used for the pseudonyms. Defaults to adjectives and animals.

seed

Random seed for permutation of name parts. Use this to make Ark reproducible (to the extent that the random number generation is reproducible). If NULL (default), the random number generator is left alone. This is a convenience argument and equivalent to calling set.seed() before creating the Ark.

Returns

A new Ark object.


Method pseudonymize()

Create Pseudonyms for input.

Usage
Ark$pseudonymize(..., .alliterate = NULL)
Arguments
...

One or more R objects.

.alliterate

Logical. Return only pseudonyms that are alliterations. Defaults to TRUE if the Ark was created with Ark$new(alliterate = TRUE), FALSE otherwise. If FALSE, pseudonyms may still be alliterations by coincidence.

Returns

Character vector of pseudonyms with same length as input.


Method print()

Pretty-print an Ark object.

Usage
Ark$print(n = NULL)
Arguments
n

A positive integer. The number of example pseudonyms to print.


Method length()

Number of used pseudonyms in an Ark.

Usage
Ark$length()

Method length_allit()

Number of used alliterations in an Ark.

Usage
Ark$length_allit()

Method clone()

The objects of this class are cloneable with this method.

Usage
Ark$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Create unique pseudonyms

Description

Pseudonymize returns unique pseudonyms for R objects. It accepts any number of vectors and data frame as arguments and will use them as keys for the pseudonym creation. Vectors and data frames must have identical length. Elements in the same position or row are treated as part of the same key. The same key is always assigned the same pseudonym. Different keys are always assigned different pseudonyms.

Usage

pseudonymize(..., .alliterate = NULL, .ark = NULL)

Arguments

...

One or multiple objects to use as keys for which pseudonyms should be created, usually one or more columns of a data frame. All objects must be of the same length.

.alliterate

Logical. Should only pseudonyms that are alliterations be returned? Defaults to FALSE, or TRUE if set as TRUE for the Ark provided to .ark. If set, takes precedence over the Ark's default setting.

.ark

An Ark object. If NULL (default) a new Ark is created. Using an existing Ark makes sure that the same input returns the same pseudonym.

Value

A character vector of pseudonyms.

Examples

pseudonymize("Mata Hari")