MarcRecord: R6 Class Representing a Marc21 record

MarcRecordR Documentation

R6 Class Representing a Marc21 record

Description

This is the base class used to interact with marc records

Details

This class provides functions for reading marc records from online or disk sources and to retrieve information from them.

Currently only MarcXML files are supported.

Public fields

controlfields

The control fields (00X) of the record

datafields

The data fields (>= 010) of the record

Methods

Public methods


Method get_fields()

Retrieve data fields from this record while applying optional filtering.

Usage
MarcRecord$get_fields(tag, ind_1, ind_2, simplify = FALSE)
Arguments
tag

Optional. Tag(s) for which to filter the record, must be a vector of size >= 1 and type numeric or character

ind_1

Optional. First indicator(s) for which to filter the record, must be a vector of size >= 1 and type character

ind_2

Optional. Second indicator(s) for which to filter the record, must be a vector of size >= 1 and type character

simplify

If set to true the data fields will be coerced in to a data frame before returning, otherwise a list of MarcDatafield will be returned

Returns

The requested data as either a data frame or a list, depending on simplify

Examples
record <- MarcRecord$new()
record$read_record("http://d-nb.info/gnd/11897792X/about/marcxml")

# Get fields with optional filtering
record$get_fields(tag = c(548, 550), simplify = TRUE)

Method read_record()

Read a marc record from disk or an online source. Currently only marcxml is supported.

Usage
MarcRecord$read_record(path)
Arguments
path

Path or URL of the data to read. Must be a character vector of size 1.

Examples
record <- MarcRecord$new()
record$read_record("http://d-nb.info/gnd/11897792X/about/marcxml")
record

Method print()

Print method for a marc record

Usage
MarcRecord$print(...)

Method clone()

The objects of this class are cloneable with this method.

Usage
MarcRecord$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `MarcRecord$get_fields`
## ------------------------------------------------

record <- MarcRecord$new()
record$read_record("http://d-nb.info/gnd/11897792X/about/marcxml")

# Get fields with optional filtering
record$get_fields(tag = c(548, 550), simplify = TRUE)

## ------------------------------------------------
## Method `MarcRecord$read_record`
## ------------------------------------------------

record <- MarcRecord$new()
record$read_record("http://d-nb.info/gnd/11897792X/about/marcxml")
record

davidfuhry/maRc documentation built on March 11, 2024, 8:15 p.m.