projects (version 1.1.1)

projects_author: projects_author class and its methods

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

new_projects_author(x = character())

# S3 method for projects_author as.integer(x, ...)

# S3 method for projects_author as.double(x, ...)

# S3 method for projects_author as.numeric(x, ...)

# S3 method for projects_author match(x, table, nomatch = NA_integer_, incomparables = NULL)

# S3 method for projects_author %in%(x, table)

Arguments

x

For new_projects_author(), any object. For

For the as.*() methods, a projects_author object.

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

...

further arguments passed to or from other methods.

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().

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.

<code>c()</code> method

A method for c() was also written so that the class attribute is not lost.

Details

Essentially, this is a character string of the form:

id: last_name

new_projects_author() merely coerces the object's class attribute to projects_author.

See Also

Ops; Methods_for_Nongenerics. For other S3 class-retention strategies, see Extract and [.data.frame.

Examples

Run this code
# NOT RUN {
jones <- new_projects_author("33: 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

# }
# NOT RUN {
# Not run because no authors() table is created within this example code.
jones == "jOnES"
# TRUE, assuming that the authors() table contains an author with an id of 3
# and a last_name beginning with "jones" (not case sensitive).
# }
# NOT RUN {
x <- structure("32: Clinton", class = "dummyclass")
class(c(x))     # Does not retain class
class(c(jones)) # Retains class
# }

Run the code above in your browser using DataCamp Workspace