projects_author: 'projects_author' vector

Description Usage Arguments Details Numeric coercion methods Equality and value matching methods See Also Examples

View source: R/class-projects_author.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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 projects_author(), an integer or character vector. For

For match() and %in%, an integer, a character string, or a projects_author object. See match() and Equality and value matching methods below.

table

An integer number, a character string, or a projects_author object. See match() and Equality and value matching methods below.

nomatch

See match().

incomparables

An integer number, a character string, or a projects_author object. See match().

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

Ops; Methods_for_Nongenerics.

Examples

 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
#############################################################################
# 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)

projects documentation built on April 24, 2021, 5:06 p.m.