Learn R Programming

dataset (version 0.3.4)

subject: Create/add/retrieve a subject

Description

Create/add/retrieve a subject

Usage

subject(x)

subject_create( term, schemeURI = NULL, valueURI = NULL, prefix = NULL, subjectScheme = NULL, classificationCode = NULL )

subject(x) <- value

is.subject(x)

Value

subject(x) returns the subject attribute of the dataset_df object x, subject(x)<-value sets the same attribute to value and invisibly returns the x object with the changed attributes.

A subject_create returns a named list with the subject term, the subject scheme, URIs and prefix.

is.subject returns a logical value, TRUE if the subject as a list is well-formatted by subject_create with its necessary key-value pairs.

Arguments

x

A dataset object created with dataset_df or dataset::as_dataset_df.

term

A subject term, for example, "Data sets".

schemeURI

The URI of the subject identifier scheme, for example "http://id.loc.gov/authorities/subjects"

valueURI

The URI of the subject term. "https://id.loc.gov/authorities/subjects/sh2018002256"

prefix

An abbreviated prefix of a scheme URI, for example, "lcch:" representing "http://id.loc.gov/authorities/subjects". Widely used namespaces (schemes) have conventional abbreviations.

subjectScheme

The name of the subject scheme or classification code or authority if one is used. It is a namespace.

classificationCode

The classificationCode subproperty may be used for subject schemes, like ANZSRC, which do not have valueURIs for each subject term.

value

A subject field created by subject. The subject field is overwritten with this value.

Details

The subject class and its function record the subject property of the dataset. The DataCite definition allows the use of multiple subproperties, however, these cannot be added to the standard utils::bibentry object. Therefore, if the user sets the value of the subject field to a character string, it is added to the bibentry of the dataset, and also to a separate subject attribute. If the user wants to use the more detailed subproperties (see examples with subject_create), then the subject$term value is added to the bibentry as a text, and the more complex subject object is added as a separate attribute to the dataset_df object.#'

Examples

Run this code
# To set the subject of a dataset_df object:
subject(iris_dataset) <- subject_create(
         term  = "Irises (plants)",
         schemeURI = "http://id.loc.gov/authorities/subjects",
         valueURI = "https://id.loc.gov/authorities/subjects/sh85068079",
         subjectScheme = "LCCH",
         prefix = "lcch:")

# To retrieve the subject with its subproperties:
subject(iris_dataset)

Run the code above in your browser using DataLab