Skip to contents

R6 class representing a generic data structure for a Darwin Core archive file

Format

R6Class object.

Details

The DwcGeneric class serves a base class to all Darwin Core archive file types. This class supports all kinds of Darwin Core archive files but may miss some of the specialised functionality of the more specialist classes. See https://dwc.tdwg.org/terms/the Darwin core reference guide for more information on Darwin core classes and the terms supported by them.

See also

DwCTerm

DwCTerm

Methods


Method setTableName()

Set the name of the file that the data will print to when preparing the Darwin core archive

Usage

DwCGeneric$setTableName(inTableName)

Arguments

inFileName

A character scalar giving the name to give the data file in a Darwin core archive


Method getTableName()

Retrieve the name of the file that the data will print to when preparing the Darwin core archive

Usage

DwCGeneric$getTableName()

Returns

The name currently set as the file name in the output archive


Method importDataTable()

Import data from a data.frame into a DwCGeneric object

Usage

DwCGeneric$importDataTable(objectData, idColumnInfo, ...)

Arguments

objectData

A data.frame containing the data to import into the object

idColumnInfo

Either a character scalar containing the column name of objectData or an integer scalar giving the index of the column of objectData that corresponds to the ID variable

...

A named set of parameter corresponding to Darwin core terms associated with the DwCGeneric class type. Each is either a a character scalar containing the column name of objectData or an integer scalar giving the index of the column of objectData that corresponds to the term


Method new()

Create a new DwCGeneric object

Usage

DwCGeneric$new(
  classTermInfo,
  associatedTerms,
  objectData,
  idColumnInfo,
  nameAutoMap = FALSE,
  defDateFormat = "YYYY-MM-DD",
  ...
)

Arguments

classTermInfo

A DwCTerm object containing the term information for the class

associatedTerms

A list of DwCTerm objects that contain all the terms associated with the class

objectData

A data.frame containing the data to import into the object

idColumnInfo

Either a character scalar containing the column name of objectData or an integer scalar giving the index of the column of objectData that corresponds to the ID variable

nameAutoMap

A logical scalar that if TRUE maps the columns of objectData to their respective Darwin core terms based on the column names

defDateFormat

A character scalar providing the default format for strings denoting dates in the data table. See the https://dwc.tdwg.org/text/#1-introductionDarwin Core text guide for expected values for this string.

...

A named set of parameter corresponding to Darwin core terms associated with the DwCGeneric class type. Each is either a a character scalar containing the column name of objectData or an integer scalar giving the index of the column of objectData that corresponds to the term

Returns

A new DwCGeneric object


Method getDwCClassName()

Retrieve the name of the class used in Darwin core

Usage

DwCGeneric$getDwCClassName()

Returns

A character scalar contining the name of the Darwin core class


Method getDwCTermInfo()

Retrieve the term information of thee Darwin core class of the object

Usage

DwCGeneric$getDwCTermInfo()

Returns

A DwCTerm object containing the term information of the Darwin core class of the object


Method getTermMapping()

Retrieve the mapping information of the Darwin core terms associated with the class to the columns in the data table

Usage

DwCGeneric$getTermMapping()

Returns

A data.frame with one row for each Darwin core term associated with the object's class with two columns: columnIndex containing the column index of the associated term in the table and columnName containg the name of the column


Method getAssociatedTerms()

Retrieve the terms associated with the Darwin core class of the object

Usage

DwCGeneric$getAssociatedTerms()

Returns

A list of DwCTerm objects containing the term information Print object to console


Method print()

Print the term information

Usage

DwCGeneric$print()


Method exportAsDataFrame()

Export the data contained in the table as a data.frame

Usage

DwCGeneric$exportAsDataFrame()

Returns

A data.frame of the object's table data


Method exportTable()

Export the table as a text file

Usage

DwCGeneric$exportTable(
  fileName,
  append = FALSE,
  quote = TRUE,
  sep = "\t",
  eol = "\n",
  na = "NA",
  dec = ".",
  qmethod = "escape",
  fileEncoding = "",
  renameMapped = FALSE
)

Arguments

fileName

Either a character string naming a file or a connection open for writing. "" indicates to the console.

append

A logical scalar. Only relevant if fileName is a character string. If TRUE, the output is appended to the file. If FALSE, any existing file of the name is destroyed.

quote

A logical scalar or a numeric vector. If TRUE, any character or factor columns will be surrounded by double quotes. If a numeric vector, its elements are taken as the indeces of columns to quote. In both cases, row and column names are quoted if they are written. If FALSE, nothing is quoted.

sep

The field seperator stirng. Values within each row are separated by this string.

eol

The character(s) to print at the end of each line (row).

na

The string to use for missing values in the data.

dec

The string to use for decimal points in numeric or complex columns: must be a single character

qmethod

A character string specifying how to deal with embedded double quote characters when quoting strings. Must be one of "escape", in which case the quote character is escaped in C style by a backslash, or "double", in which case it is doubled

fileEncoding

A character string. If non-empty, declares the encoding to be used on a file so the character data can be re-encoded as they are written

renameMapped

A logical scalar that, if TRUE, replaces mapped column names with their Darwin core versions


Method getIDIndex()

Retrieve the column index in the dataset that refers to the unique ID in the dataset

Usage

DwCGeneric$getIDIndex()

Returns

An integer scalar giving the index of the column that refers to the unique dataset IDs


Method getIDName()

Retrieve the column name in the dataset that refers to the unique ID in the dataset

Usage

DwCGeneric$getIDName()

Returns

A character scalar giving the column name that refers to the unique dataset IDs


Method setDefaultYearFormat()

Set the default date format in the dataset

Usage

DwCGeneric$setDefaultYearFormat(detDateFormat)

Arguments

detDateFormat

A character scalar providing the default format for strings denoting dates in the data table. See the https://dwc.tdwg.org/text/#1-introductionDarwin Core text guide for expected values for this string.


Method getDefaultYearFormat()

Retrieve the default date format

Usage

DwCGeneric$getDefaultYearFormat()

Returns

A character scalar containing the default date format


Method getTableTermName()

Retrieve the term name for the table

Usage

DwCGeneric$getTableTermName()

Returns

A character scalar containing the name to the term defining the table


Method clone()

The objects of this class are cloneable with this method.

Usage

DwCGeneric$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.