R6 class representing a generic data structure for a Darwin Core archive file
R6Class
object.
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.
DwCTerm
DwCTerm
setTableName()
Set the name of the file that the data will print to when preparing the Darwin core archive
getTableName()
Retrieve the name of the file that the data will print to when preparing the Darwin core archive
importDataTable()
Import data from a data.frame
into a DwCGeneric
object
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
new()
Create a new DwCGeneric object
DwCGeneric$new(
classTermInfo,
associatedTerms,
objectData,
idColumnInfo,
nameAutoMap = FALSE,
defDateFormat = "YYYY-MM-DD",
...
)
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
getTermMapping()
Retrieve the mapping information of the Darwin core terms associated with the class to the columns in the data table
exportTable()
Export the table as a text file
DwCGeneric$exportTable(
fileName,
append = FALSE,
quote = TRUE,
sep = "\t",
eol = "\n",
na = "NA",
dec = ".",
qmethod = "escape",
fileEncoding = "",
renameMapped = FALSE
)
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
getIDIndex()
Retrieve the column index in the dataset that refers to the unique ID in the dataset
getIDName()
Retrieve the column name in the dataset that refers to the unique ID in the dataset
setDefaultYearFormat()
Set the default date format in the dataset
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.