| projects_author {projects} | R Documentation |
projects_author vector
Description
Objects of this class contain both the id and the last_name of
an author so that the package and the user, respectively, can easily identify
the author.
Usage
projects_author(x = character())
match.projects_author(x, table, nomatch = NA_integer_, incomparables = NULL)
## S4 method for signature 'projects_author,ANY'
match(x, table, nomatch = NA_integer_, incomparables = NULL)
## S4 method for signature 'ANY,projects_author'
match(x, table, nomatch = NA_integer_, incomparables = NULL)
## S4 method for signature 'projects_author,projects_author'
match(x, table, nomatch = NA_integer_, incomparables = NULL)
`%in%.projects_author`(x, table)
## S4 method for signature 'projects_author'
x %in% table
Arguments
x |
For For |
table |
An integer number, a character string, or a
|
nomatch |
See |
incomparables |
An integer number, a character string, or a
|
Details
Essentially, this is a character string of the form:
id: last_name
projects_author() coerces an integer or character vector to a
projects_author object, validating each element against the existing
authors() table.
Numeric coercion methods
as.integer(),
as.double(), and as.numeric() return the
id portion of the projects_author object as an
integer/double. The methods for the equality and value matching functions
described below make use of these numeric coercion methods. Users desiring
to apply value matching functions other than the ones described below may
similarly take advantage of these.
Equality and value matching methods
Methods for ==,
!=, match(), and %in% enable
users to test equality and to value match among projects_author
objects and as well as between projects_author objects and unclassed
numbers/characters. When testing or matching against a numeric vector, the
projects_author object is first coerced to an integer with the
as.integer() method described above. When testing or matching
against a character vector, the character vector is validated against the
authors() table.
See Also
Examples
#############################################################################
# SETUP
old_home <- Sys.getenv("HOME")
old_ppath <- Sys.getenv("PROJECTS_FOLDER_PATH")
temp_dir <- tempfile("dir")
dir.create(temp_dir)
Sys.unsetenv("PROJECTS_FOLDER_PATH")
Sys.setenv(HOME = temp_dir)
setup_projects(path = temp_dir)
new_author("chuck", "jonesman", id = 33)
new_author("Hattie", "Hatsman", id = 45)
#############################################################################
jones <- projects_author("33: Jones")
jones
as.integer(jones) # 33
jones == 33 # TRUE
jones == 10 # FALSE
jones != 33 # FALSE
jones %in% c(20:40) # TRUE
match(jones, c(31:40)) # 3
# Comparing a projects_author object to a character vector results in the
# character strings being validated against the authors() table. Then, the id
# numbers are compared.
jones == c("jOnES", "hat") # TRUE FALSE
#############################################################################
# Cleanup (or just restart R)
Sys.setenv(HOME = old_home, PROJECTS_FOLDER_PATH = old_ppath)