projects (version 1.1.1)

projects_stage: projects_stage class and its methods

Description

Objects of this class are merely a character string containing a number and a name of one of seven project development stages.

Usage

new_projects_stage(x = character())

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

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

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

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

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

Arguments

x

For new_projects_stage(), any object. For

For the as.*() methods, a projects_stage 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 stage number of the projects_author object as an integer/double. The methods for the comparison 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.

Comparison and value matching methods

Methods for the Comparison operators as well as match() and %in% enable users to test equality and to value match among projects_stage objects and as well as between projects_stage objects and unclassed numbers/characters. When comparing or value matching against a numeric vector, the projects_stage object is first coerced to an integer with the as.integer() method described above. When testing or value matching against a character vector, the character vector is validated against the list of project stages enumerated above.

<code>c()</code> method

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

Details

A projects_stage object is either a missing value (NA) or one of:

0: idea 1: design 2: data collection 3: analysis 4: manuscript 5: under review 6: accepted

new_projects_stage() merely coerces the object's class attribute to projects_stage.

See Also

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

Examples

Run this code
# NOT RUN {
stage <- new_projects_stage("4: manuscript")

as.integer(stage) # 4

stage == 4       # TRUE
stage != 4       # FALSE
stage <  6       # TRUE

stage %in% c(3:6)  # TRUE
match(stage, 0:4)  # 5

stage %in% c("design", "manusc", "idea")  # TRUE

more_stages <- new_projects_stage(c("0: idea", "4: manuscript", "1: design"))

match("MAnuscRIPT", more_stages)      # 2

x <- structure("7: redacted", class = "dummyclass")
class(c(x))     # Does not retain class
class(c(stage, more_stages)) # Retains class
# }

Run the code above in your browser using DataLab