Manage the subject metadata of a dataset. The subject can be stored as a
simple character term or as a structured object with subproperties created by
subject_create().
Usage
subject(x)
subject_create(
term,
schemeURI = NULL,
valueURI = NULL,
prefix = NULL,
subjectScheme = NULL,
classificationCode = NULL
)
subject(x) <- value
is.subject(x)Arguments
- x
A dataset object created with
dataset_df()oras_dataset_df().- term
A subject term, for example
"Data sets".- schemeURI
URI of the subject identifier scheme, for example
"http://id.loc.gov/authorities/subjects".- valueURI
URI of the subject term, for example
"https://id.loc.gov/authorities/subjects/sh2018002256".- prefix
Abbreviated prefix for a scheme URI, for example
"lcch:". Widely used namespaces (schemes) have conventional abbreviations.- subjectScheme
Name of the subject scheme, classification code, or authority if one is used. This acts as a namespace.
- classificationCode
Classification code for schemes that do not have
valueURIentries for each subject term (e.g., ANZSRC).- value
A subject object created by
subject_create()or a character string. Used bysubject<-to replace the subject.
Value
subject(x)returns:a single
"subject"object if only one is present,a list of
"subject"objects if multiple are present,otherwise falls back to the plain string from the bibentry.
subject(x) <- valueaccepts a character vector, a"subject"object, or a list of"subject"objects, and updates both the bibentry slot and the"subject"attribute. Returns the dataset invisibly.subject_create()returns a structured"subject"object — or a list of them if multiple terms are provided.is.subject(x)returnsTRUEifxinherits from class"subject".
Details
The subject property records what the dataset is about.
The DataCite subject property
allows multiple subproperties, but these cannot be stored directly in a
standard utils::bibentry object.
Therefore:
If you set a character string as the subject, it is stored in both the bibentry and the
"subject"attribute.If you set a structured subject (via
subject_create()), the$termvalue is stored in the bibentry, and the full object is stored in the"subject"attribute of thedataset_dfobject.
See also
Other bibliographic helper functions:
contributor(),
creator(),
dataset_format(),
dataset_title(),
description(),
geolocation(),
get_bibentry(),
language,
publication_year(),
publisher(),
relation(),
rights()
Examples
# Set a structured subject
subject(orange_df) <- subject_create(
term = "Oranges",
schemeURI = "http://id.loc.gov/authorities/subjects",
valueURI = "http://id.loc.gov/authorities/subjects/sh85095257",
subjectScheme = "LCCH",
prefix = "lcch:"
)
# Retrieve subject with subproperties
subject(orange_df)
#> $term
#> [1] "Oranges"
#>
#> $subjectScheme
#> [1] "LCCH"
#>
#> $schemeURI
#> [1] "http://id.loc.gov/authorities/subjects"
#>
#> $valueURI
#> [1] "http://id.loc.gov/authorities/subjects/sh85095257"
#>
#> $classificationCode
#> NULL
#>
#> $prefix
#> [1] "lcch:"
#>
#> attr(,"class")
#> [1] "subject" "list"
