Collection {stoRy} | R Documentation |
R6 class representing a collection of LTO thematically annotated stories
Description
The stoRy package uses the Collection
R6 class to represent a set
of related LTO thematically annotated stories. This class is mostly useful
for accessing information about a collection of stories for which the
collection ID is known in advance.
Details
The class operates on the story collection of whichever LTO version happens
to be actively loaded into the stoRy package level environment. This
is the LTO demo
version by default. Run which_lto()
to check which LTO
version is active in your R session.
Search the latest LTO dev
version collections on the Theme Ontology
website at https://www.themeontology.org/stories.
Alternatively, it is possible to read in a user-defined collection from
file. In this case, the collection ID as defined in the file must match the
collection_id
input parameter.
Methods
Public methods
Method new()
Initialize a collection of LTO thematically annotated stories.
Usage
Collection$new(collection_id, file = NULL, verbose = TRUE)
Arguments
collection_id
A length-one character vector corresponding to the ID of an LTO collection of stories.
file
A file name of a collection file or path to a collection file or a string. Files must end with the standard .st.txt extension used for story and collection files.
If
file
is a file name, then the file is assumed to reside in the current working directory.verbose
A logical value indicating whether status messages should be output to console.
Returns
A new Collection
object.
Method collection_id()
return A length-one character vector corresponding to the collection ID.
Usage
Collection$collection_id()
Method title()
return A length-one character vector corresponding to the collection title.
Usage
Collection$title()
Method description()
return A length-one character vector of collection defining text.
Usage
Collection$description()
Method date()
return A length-one character vector typically of the form "yyyy-yyyy" indicating the start and end year for stories in the collection.
Usage
Collection$date()
Method references()
return A tibble of collection reference urls, if any.
Usage
Collection$references()
Method component_story_ids()
return A tibble of member story IDs.
Usage
Collection$component_story_ids()
Method themes()
return A tibble of thematic annotations.
Usage
Collection$themes()
Method source()
return The path of the st.txt collection file. This is the file path as it occurs on the Theme Ontology GitHub repository at https://github.com/theme-ontology/theming.
Usage
Collection$source()
Method size()
return A length-one numeric vector containing the number of stories in the collection.
Usage
Collection$size()
Method obj_internal_tbl()
return A special tibble that is used internally by package functions.
Usage
Collection$obj_internal_tbl()
Method print()
Print collection object info to console.
Usage
Collection$print(canonical = FALSE, n = NULL, width = NULL, ...)
Arguments
canonical
Set to FALSE for pretty output.
n
Maximum number of component story IDs to print to console. This defaults to NULL which means the
stoRy_opt("print_min")
value is used. Runoptions(stoRy.print_min = 25L)
to set the minimum number of printed component story IDs to be 25. RunstoRy_opt("print_max")
to check the maximum number of stories that can be printed to console. This value can be changed in the same way as withstoRy.print_min
.width
Width of text output to generate. This defaults to NULL, which means the
stoRy_opt("width")
value is used. Runoptions(stoRy.width = 120L)
to change the column width to be 120 characters, etc....
Additional arguments
Method clone()
The objects of this class are cloneable with this method.
Usage
Collection$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Use Story()
to initialize an LTO thematically annotated story.
Use Theme()
to initialize an LTO theme.
Use Themeset()
to initialize a set of related LTO themes.
Examples
## Not run:
# Initialize a collection:
set_lto("demo")
collection <- Collection$new(collection_id = "Collection: tvseries: The Twilight Zone (1959)")
# Print collection info to console:
collection
# Print collection info in canonical st.txt format:
collection$print(canonical = TRUE)
# Initialize a collection from file:
set_lto("demo")
file <- system.file("extdata/rolling-stone-best-ttz1959-episodes.st.txt", package = "stoRy")
collection_id <- "Collection: Rolling Stone 25 Best Twilight Zone Original Series Episodes"
collection <- Collection$new(collection_id, file)
collection
# Initialize a collection from a string:
set_lto("demo")
file <- I("Collection: Rolling Stone 25 Best Twilight Zone Original Series Episodes
========================================================================
:: Title
Rolling Stone 25 Best Twilight Zone Original Series Episodes
:: Date
1959-1964
:: Description
Rolling Stone Magazine's list of the 25 best episodes from the original
Twilight Zone anthology television series, which ran for five seasons on CBS
from 1959 to 1964, as compiled by David Fear, Sean T. Collins, and Angie
Martoccio.
:: References
https://www.rollingstone.com/tv/tv-features/25-best-twilight-zone-episodes-list-812043/
:: Collections
Collection: Rolling Stone 25 Best Twilight Zone Original Series Episodes
:: Component Stories
tz1959e3x24
tz1959e1x22
tz1959e2x06
tz1959e5x03
tz1959e2x15
tz1959e2x28
tz1959e1x08
tz1959e3x14
tz1959e3x05
tz1959e5x06
tz1959e3x08
tz1959e1x01
tz1959e1x21
tz1959e1x34
tz1959e2x07
tz1959e1x13
tz1959e1x09
tz1959e3x10
tz1959e1x16
tz1959e1x28
tz1959e1x30
tz1959e3x33
tz1959e3x01
tz1959e2x22
tz1959e5x25")
collection_id <- unlist(strsplit(file, split = "\n"))[1]
collection <- Collection$new(collection_id, file)
collection
## End(Not run)