A class and utility methods for holding information about persons like name and email address.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
person(given = NULL, family = NULL, middle = NULL, email = NULL, role = NULL, comment = NULL, first = NULL, last = NULL) ## Default S3 method: as.person(x) ## S3 method for class 'person' format(x, include = c("given", "family", "email", "role", "comment"), braces = list(given = "", family = "", email = c("<", ">"), role = c("[", "]"), comment = c("(", ")")), collapse = list(given = " ", family = " ", email = ", ", role = ", ", comment = ", "), ..., style = c("text", "R") )
a character vector with the given names, or a list thereof.
a character string with the family name, or a list thereof.
a character string with the collapsed middle name(s). Deprecated, see Details.
a character string giving the email address, or a list thereof.
a character string specifying the role of the person (see Details), or a list thereof.
a character string providing a comment, or a list thereof.
a character string giving the first name. Deprecated, see Details.
a character string giving the last name. Deprecated, see Details.
a character string for the
a character vector giving the fields to be included when formatting.
a list of characters (see Details).
a list of characters (see Details).
currently not used.
a character string specifying the print style, with
Objects of class
"person" can hold information about an
arbitrary positive number of persons. These can be obtained by one
person() with list arguments, or by first creating
objects representing single persons and combining these via
format() method collapses information about persons into
character vectors (one string for each person): the fields in
include are selected, each collapsed to a string using the
respective element of
collapse and subsequently
“embraced” using the respective element of
finally collapsed into one string separated by white space. If
collapse do not specify characters for all
fields, the defaults shown in the usage are imputed. The
print() method calls the
format() method and prints the
toBibtex() method creates a suitable BibTeX
Person objects can be subscripted by fields (using
$) or by
as.person() is a generic function. Its default method tries to
reverse the default person formatting, and can also handle formatted
person entries collapsed by comma or
"and" (with appropriate
Personal names are rather tricky, e.g., https://en.wikipedia.org/wiki/Personal_name.
The current implementation (starting from R 2.12.0) of the
"person" class uses the notions of given (including
middle names) and family names, as specified by
family respectively. Earlier versions used a scheme based
on first, middle and last names, as appropriate for most of Western
culture where the given name precedes the family name, but not
universal, as some other cultures place it after the family name, or
use no family name. To smooth the transition to the new scheme,
last are still
supported, but their use is deprecated and they must not be given in
combination with the corresponding new style arguments. For persons
which are not natural persons (e.g., institutions, companies, etc.) it
is appropriate to use
given (but not
family) for the
person("R Core Team", role = "aut").
The new scheme also adds the possibility of specifying roles based on a subset of the MARC Code List for Relators (https://www.loc.gov/marc/relators/relaterm.html). When giving the roles of persons in the context of authoring R packages, the following usage is suggested.
(Author) Use for full authors who have made substantial contributions to the package and should show up in the package citation.
(Compiler) Use for persons who collected code (potentially in other languages) but did not make further substantial contributions to the package.
(Contributor) Use for authors who have made smaller contributions (such as code patches etc.) but should not show up in the package citation.
(Copyright holder) Use for all copyright holders.
(Creator) Use for the package maintainer.
(Contractor) Use for authors who have been contracted to write (parts of) the package and hence do not own intellectual property.
(Data contributor) Use for persons who contributed data sets for the package.
(Thesis advisor) If the package is part of a thesis, use for the thesis advisor.
(Translator) If the R code is a translation from another language (typically S), use for the translator to R.
In the old scheme, person objects were used for single persons, and a
"personList" class with corresponding creator
personList() for collections of these. The new scheme employs
a single class for information about an arbitrary positive number of
persons, eliminating the need for the
as.person() return objects of class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
## Create a person object directly ... p1 <- person("Karl", "Pearson", email = "firstname.lastname@example.org") ## ... or convert a string. p2 <- as.person("Ronald Aylmer Fisher") ## Combining and subsetting. p <- c(p1, p2) p p[-1] ## Extracting fields. p$family p$email p$email ## Specifying package authors, example from "boot": ## AC is the first author [aut] who wrote the S original. ## BR is the second author [aut], who translated the code to R [trl], ## and maintains the package [cre]. b <- c(person("Angelo", "Canty", role = "aut", comment = "S original, http://statwww.epfl.ch/davison/BMA/library.html"), person(c("Brian", "D."), "Ripley", role = c("aut", "trl", "cre"), comment = "R port", email = "email@example.com") ) b ## Formatting. format(b) format(b, include = c("family", "given", "role"), braces = list(family = c("", ","), role = c("(Role(s): ", ")"))) ## Conversion to BibTeX author field. paste(format(b, include = c("given", "family")), collapse = " and ") toBibtex(b)