R6 class representing a generic data structure for a Darwin Core archive file
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.
Methods
Method setTableName()
Set the name of the file that the data will print to when preparing the Darwin core archive
Method getTableName()
Retrieve the name of the file that the data will print to when preparing the Darwin core archive
Method importDataTable()
Import data from a data.frame into a DwCGeneric object
Arguments
objectDataA
data.framecontaining the data to import into the objectidColumnInfoEither a
characterscalar containing the column name ofobjectDataor anintegerscalar giving the index of the column ofobjectDatathat 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
characterscalar containing the column name ofobjectDataor anintegerscalar giving the index of the column ofobjectDatathat 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
classTermInfoA
DwCTermobject containing the term information for the classassociatedTermsA
listofDwCTermobjects that contain all the terms associated with the classobjectDataA
data.framecontaining the data to import into the objectidColumnInfoEither a
characterscalar containing the column name ofobjectDataor anintegerscalar giving the index of the column ofobjectDatathat corresponds to the ID variablenameAutoMapA
logicalscalar that ifTRUEmaps the columns ofobjectDatato their respective Darwin core terms based on the column namesdefDateFormatA
characterscalar 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
characterscalar containing the column name ofobjectDataor anintegerscalar giving the index of the column ofobjectDatathat corresponds to the term
Method getTermMapping()
Retrieve the mapping information of the Darwin core terms associated with the class to the columns in the data table
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
fileNameEither a
characterstring naming a file or a connection open for writing.""indicates to the console.appendA
logicalscalar. Only relevant iffileNameis acharacterstring. IfTRUE, the output is appended to the file. IfFALSE, any existing file of the name is destroyed.quoteA
logicalscalar or anumericvector. IfTRUE, any character or factor columns will be surrounded by double quotes. If anumericvector, its elements are taken as the indeces of columns to quote. In both cases, row and column names are quoted if they are written. IfFALSE, nothing is quoted.sepThe field seperator stirng. Values within each row are separated by this string.
eolThe character(s) to print at the end of each line (row).
naThe string to use for missing values in the data.
decThe string to use for decimal points in numeric or complex columns: must be a single character
qmethodA 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 doubledfileEncodingA 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
renameMappedA
logicalscalar that, ifTRUE, 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
Method getIDName()
Retrieve the column name in the dataset that refers to the unique ID in the dataset
Method setDefaultYearFormat()
Set the default date format in the dataset
Arguments
detDateFormatA
characterscalar 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.
