MarcDatafield: R6 Class Representing a Marc21 data field

MarcDatafieldR Documentation

R6 Class Representing a Marc21 data field

Description

This is the base class used to store and interact with marc data fields

Details

This class provides the base functionality for storing marc data, as well as providing methods to retrieve that data and convert it into other formats like data.frames

Public fields

tag

Marc tag of the data field

ind_1

First indictator of the data field

ind_2

Second indictator of the data field

codes

Subfield codes in this data field

values

Subfield values of this data field

Methods

Public methods


Method to_data_frame()

Simplifies this data field by coercing it into a data frame.

Usage
MarcDatafield$to_data_frame()
Returns

A data frame containing the contents of this data field

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

data_field <- record$get_fields(tag = "550")[[1]]
data_field$to_data_frame()

Method get_values()

Retrieves values for one or more codes from the data field

Usage
MarcDatafield$get_values(codes)
Arguments
codes

The code or codes for which to retreive values. Must be a vector of size >= 1 and type character

Returns

Character vector containing the requested values if there are any, NA otherwise

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

data_field <- record$get_fields(tag = "550")[[1]]
data_field$get_values(c("i", "a"))

Method print()

Print method for a marc data field

Usage
MarcDatafield$print(...)

Method new()

Constructor method for a marc data field.

Usage
MarcDatafield$new(tag, ind_1, ind_2, codes, values)
Arguments
tag

Optional. The tag of the data field.

ind_1

Optional. First indicator of the data field.

ind_2

Optional. Second indicator of the data field.

codes

Optional. Data codes of the data field.

values

Optional. Data values of the data field.

Examples
field <- MarcDatafield$new(tag = 550,
   ind_1 = " ",
   ind_2 = " ",
   codes = c("0", "a"),
   values = c("A value", "Another value"))
field

Method clone()

The objects of this class are cloneable with this method.

Usage
MarcDatafield$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `MarcDatafield$to_data_frame`
## ------------------------------------------------

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

data_field <- record$get_fields(tag = "550")[[1]]
data_field$to_data_frame()

## ------------------------------------------------
## Method `MarcDatafield$get_values`
## ------------------------------------------------

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

data_field <- record$get_fields(tag = "550")[[1]]
data_field$get_values(c("i", "a"))

## ------------------------------------------------
## Method `MarcDatafield$new`
## ------------------------------------------------

field <- MarcDatafield$new(tag = 550,
   ind_1 = " ",
   ind_2 = " ",
   codes = c("0", "a"),
   values = c("A value", "Another value"))
field

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