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
objectData
A
data.frame
containing the data to import into the objectidColumnInfo
Either a
character
scalar containing the column name ofobjectData
or aninteger
scalar giving the index of the column ofobjectData
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 ofobjectData
or aninteger
scalar giving the index of the column ofobjectData
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 classassociatedTerms
A
list
ofDwCTerm
objects that contain all the terms associated with the classobjectData
A
data.frame
containing the data to import into the objectidColumnInfo
Either a
character
scalar containing the column name ofobjectData
or aninteger
scalar giving the index of the column ofobjectData
that corresponds to the ID variablenameAutoMap
A
logical
scalar that ifTRUE
maps the columns ofobjectData
to their respective Darwin core terms based on the column namesdefDateFormat
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 ofobjectData
or aninteger
scalar giving the index of the column ofobjectData
that 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
fileName
Either a
character
string naming a file or a connection open for writing.""
indicates to the console.append
A
logical
scalar. Only relevant iffileName
is acharacter
string. IfTRUE
, the output is appended to the file. IfFALSE
, any existing file of the name is destroyed.quote
A
logical
scalar or anumeric
vector. IfTRUE
, any character or factor columns will be surrounded by double quotes. If anumeric
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. IfFALSE
, 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 doubledfileEncoding
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, 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
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.