package ‘eml’ · 2017. 11. 17. · 2 c,section-method r topics documented: c,section-method . ....
TRANSCRIPT
Package ‘EML’May 2, 2017
Type Package
Title Read and Write Ecological Metadata Language Files
Version 1.0.3
URL https://github.com/ropensci/EML
BugReports https://github.com/ropensci/EML/issues
Maintainer Carl Boettiger <[email protected]>
Description Parse and serialize Ecological Metadata Language ('EML', see<https://en.wikipedia.org/wiki/Ecological_Metadata_Language> formore information) files into S4 objects.
License FreeBSD
LazyData TRUE
RoxygenNote 6.0.1
Imports xml2 (>= 1.1.1), methods, tools, uuid
Suggests testthat, knitr, rmarkdown, listviewer, covr
VignetteBuilder knitr
Encoding UTF-8
Collate 'classes.R' 'classes-stmml.R' 'coercions.R' 'eml_find.R''get_unitList.R' 'get_attributes.R' 'eml_get.R''eml_validate.R' 'eml_view.R' 'get_TextType.R' 'get_coverage.R''is_standardUnit.R' 'literature_coercions.R' 'methods.R''read_eml.R' 's4_to_xml.R' 'set_TextType.R' 'set_attributes.R''set_coverage.R' 'set_methods.R' 'set_physical.R''set_unitList.R' 'show_methods.R' 'write_eml.R' 'xml_to_s4.R''zzz.R'
NeedsCompilation no
Author Carl Boettiger [aut, cre],Matthew B. Jones [aut],Bryce Mecum [ctb],Maëlle Salmon [ctb]
Repository CRAN
Date/Publication 2017-05-01 22:13:08 UTC
1
2 c,section-method
R topics documented:c,section-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2eml_find . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8eml_get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8eml_locate_schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10eml_validate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10eml_view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11get_attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12get_taxonomicCoverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13get_TextType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14get_unitList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15is_standardUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16read_eml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16set_attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17set_coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18set_methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19set_physical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20set_taxonomicCoverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22set_TextType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23set_unitList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24write_eml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Index 28
c,section-method concatenate
Description
concatenate
Usage
## S4 method for signature 'section'c(x, ..., recursive = FALSE)
## S4 method for signature 'para'c(x, ..., recursive = FALSE)## S4 method for signature 'value'c(x, ..., recursive = FALSE)## S4 method for signature 'itemizedlist'c(x, ..., recursive = FALSE)## S4 method for signature 'orderedlist'c(x, ..., recursive = FALSE)## S4 method for signature 'emphasis'c(x, ..., recursive = FALSE)## S4 method for signature 'subscript'
c,section-method 3
c(x, ..., recursive = FALSE)## S4 method for signature 'superscript'c(x, ..., recursive = FALSE)## S4 method for signature 'literalLayout'c(x, ..., recursive = FALSE)## S4 method for signature 'citetitle'c(x, ..., recursive = FALSE)## S4 method for signature 'ulink'c(x, ..., recursive = FALSE)## S4 method for signature 'listitem'c(x, ..., recursive = FALSE)## S4 method for signature 'individualName'c(x, ..., recursive = FALSE)## S4 method for signature 'organizationName'c(x, ..., recursive = FALSE)## S4 method for signature 'positionName'c(x, ..., recursive = FALSE)## S4 method for signature 'address'c(x, ..., recursive = FALSE)## S4 method for signature 'phone'c(x, ..., recursive = FALSE)## S4 method for signature 'electronicMailAddress'c(x, ..., recursive = FALSE)## S4 method for signature 'onlineUrl'c(x, ..., recursive = FALSE)## S4 method for signature 'userId'c(x, ..., recursive = FALSE)## S4 method for signature 'salutation'c(x, ..., recursive = FALSE)## S4 method for signature 'givenName'c(x, ..., recursive = FALSE)## S4 method for signature 'deliveryPoint'c(x, ..., recursive = FALSE)## S4 method for signature 'alternateIdentifier'c(x, ..., recursive = FALSE)## S4 method for signature 'title'c(x, ..., recursive = FALSE)## S4 method for signature 'creator'c(x, ..., recursive = FALSE)## S4 method for signature 'metadataProvider'c(x, ..., recursive = FALSE)## S4 method for signature 'associatedParty'c(x, ..., recursive = FALSE)## S4 method for signature 'keyword'c(x, ..., recursive = FALSE)## S4 method for signature 'keywordSet'c(x, ..., recursive = FALSE)## S4 method for signature 'additionalInfo'
4 c,section-method
c(x, ..., recursive = FALSE)## S4 method for signature 'distribution'c(x, ..., recursive = FALSE)## S4 method for signature 'parameterDefinition'c(x, ..., recursive = FALSE)## S4 method for signature 'mediumFormat'c(x, ..., recursive = FALSE)## S4 method for signature 'parameter'c(x, ..., recursive = FALSE)## S4 method for signature 'altitudeResolution'c(x, ..., recursive = FALSE)## S4 method for signature 'depthResolution'c(x, ..., recursive = FALSE)## S4 method for signature 'horizCoordSysDef'c(x, ..., recursive = FALSE)## S4 method for signature 'allow'c(x, ..., recursive = FALSE)## S4 method for signature 'deny'c(x, ..., recursive = FALSE)## S4 method for signature 'principal'c(x, ..., recursive = FALSE)## S4 method for signature 'permission'c(x, ..., recursive = FALSE)## S4 method for signature 'attributeReference'c(x, ..., recursive = FALSE)## S4 method for signature 'contact'c(x, ..., recursive = FALSE)## S4 method for signature 'editor'c(x, ..., recursive = FALSE)## S4 method for signature 'institution'c(x, ..., recursive = FALSE)## S4 method for signature 'recipient'c(x, ..., recursive = FALSE)## S4 method for signature 'geographicCoverage'c(x, ..., recursive = FALSE)## S4 method for signature 'publicationPlace'c(x, ..., recursive = FALSE)## S4 method for signature 'performer'c(x, ..., recursive = FALSE)## S4 method for signature 'temporalCoverage'c(x, ..., recursive = FALSE)## S4 method for signature 'taxonomicCoverage'c(x, ..., recursive = FALSE)## S4 method for signature 'singleDateTime'c(x, ..., recursive = FALSE)## S4 method for signature 'timeScaleCitation'c(x, ..., recursive = FALSE)## S4 method for signature 'gRingPoint'
c,section-method 5
c(x, ..., recursive = FALSE)## S4 method for signature 'datasetGPolygonExclusionGRing'c(x, ..., recursive = FALSE)## S4 method for signature 'datasetGPolygon'c(x, ..., recursive = FALSE)## S4 method for signature 'classificationSystem'c(x, ..., recursive = FALSE)## S4 method for signature 'identificationReference'c(x, ..., recursive = FALSE)## S4 method for signature 'identifierName'c(x, ..., recursive = FALSE)## S4 method for signature 'originator'c(x, ..., recursive = FALSE)## S4 method for signature 'vouchers'c(x, ..., recursive = FALSE)## S4 method for signature 'taxonomicClassification'c(x, ..., recursive = FALSE)## S4 method for signature 'commonName'c(x, ..., recursive = FALSE)## S4 method for signature 'authentication'c(x, ..., recursive = FALSE)## S4 method for signature 'compressionMethod'c(x, ..., recursive = FALSE)## S4 method for signature 'encodingMethod'c(x, ..., recursive = FALSE)## S4 method for signature 'recordDelimiter'c(x, ..., recursive = FALSE)## S4 method for signature 'physicalLineDelimiter'c(x, ..., recursive = FALSE)## S4 method for signature 'fieldDelimiter'c(x, ..., recursive = FALSE)## S4 method for signature 'quoteCharacter'c(x, ..., recursive = FALSE)## S4 method for signature 'literalCharacter'c(x, ..., recursive = FALSE)## S4 method for signature 'textFixed'c(x, ..., recursive = FALSE)## S4 method for signature 'textDelimited'c(x, ..., recursive = FALSE)## S4 method for signature 'role'c(x, ..., recursive = FALSE)## S4 method for signature 'personnel'c(x, ..., recursive = FALSE)## S4 method for signature 'descriptorValue'c(x, ..., recursive = FALSE)## S4 method for signature 'citation'c(x, ..., recursive = FALSE)## S4 method for signature 'descriptor'
6 c,section-method
c(x, ..., recursive = FALSE)## S4 method for signature 'coverage'c(x, ..., recursive = FALSE)## S4 method for signature 'description'c(x, ..., recursive = FALSE)## S4 method for signature 'relatedProject'c(x, ..., recursive = FALSE)## S4 method for signature 'operatingSystem'c(x, ..., recursive = FALSE)## S4 method for signature 'machineProcessor'c(x, ..., recursive = FALSE)## S4 method for signature 'programmingLanguage'c(x, ..., recursive = FALSE)## S4 method for signature 'implementation'c(x, ..., recursive = FALSE)## S4 method for signature 'licenseURL'c(x, ..., recursive = FALSE)## S4 method for signature 'license'c(x, ..., recursive = FALSE)## S4 method for signature 'proceduralStep'c(x, ..., recursive = FALSE)## S4 method for signature 'dataSource'c(x, ..., recursive = FALSE)## S4 method for signature 'methodStep'c(x, ..., recursive = FALSE)## S4 method for signature 'referencedEntityId'c(x, ..., recursive = FALSE)## S4 method for signature 'sampling'c(x, ..., recursive = FALSE)## S4 method for signature 'qualityControl'c(x, ..., recursive = FALSE)## S4 method for signature 'protocol'c(x, ..., recursive = FALSE)## S4 method for signature 'instrumentation'c(x, ..., recursive = FALSE)## S4 method for signature 'software'c(x, ..., recursive = FALSE)## S4 method for signature 'subStep'c(x, ..., recursive = FALSE)## S4 method for signature 'attribute'c(x, ..., recursive = FALSE)## S4 method for signature 'attributeLabel'c(x, ..., recursive = FALSE)## S4 method for signature 'storageType'c(x, ..., recursive = FALSE)## S4 method for signature 'missingValueCode'c(x, ..., recursive = FALSE)## S4 method for signature 'quantitativeAttributeAccuracyAssessment'
c,section-method 7
c(x, ...,recursive = FALSE)
## S4 method for signature 'codeDefinition'c(x, ..., recursive = FALSE)## S4 method for signature 'codesetURL'c(x, ..., recursive = FALSE)## S4 method for signature 'enumeratedDomain'c(x, ..., recursive = FALSE)## S4 method for signature 'pattern'c(x, ..., recursive = FALSE)## S4 method for signature 'textDomain'c(x, ..., recursive = FALSE)## S4 method for signature 'bounds'c(x, ..., recursive = FALSE)## S4 method for signature 'constraint'c(x, ..., recursive = FALSE)## S4 method for signature 'physical'c(x, ..., recursive = FALSE)## S4 method for signature 'geometry'c(x, ..., recursive = FALSE)## S4 method for signature 'quantitativeAccuracyReport'c(x, ..., recursive = FALSE)## S4 method for signature 'cornerPoint'c(x, ..., recursive = FALSE)## S4 method for signature 'controlPoint'c(x, ..., recursive = FALSE)## S4 method for signature 'bandDescription'c(x, ..., recursive = FALSE)## S4 method for signature 'dataTable'c(x, ..., recursive = FALSE)## S4 method for signature 'spatialRaster'c(x, ..., recursive = FALSE)## S4 method for signature 'spatialVector'c(x, ..., recursive = FALSE)## S4 method for signature 'storedProcedure'c(x, ..., recursive = FALSE)## S4 method for signature 'view'c(x, ..., recursive = FALSE)## S4 method for signature 'otherEntity'c(x, ..., recursive = FALSE)## S4 method for signature 'changeHistory'c(x, ..., recursive = FALSE)## S4 method for signature 'describes'c(x, ..., recursive = FALSE)## S4 method for signature 'additionalMetadata'c(x, ..., recursive = FALSE)## S4 method for signature 'dimension'c(x, ..., recursive = FALSE)
8 eml_get
## S4 method for signature 'unit'c(x, ..., recursive = FALSE)## S4 method for signature 'unitType'c(x, ..., recursive = FALSE)
Arguments
x, ... otherEntities to concatenate
recursive Needed for compatibility with generic, otherwise ignored
eml_find eml_find
Description
find all occurrences of an EML element in at a given node at any depth
Usage
eml_find(node, element)
Arguments
node an EML S4 object; e.g. ‘eml‘ or any of it’s child/descendant slots.
element the name of an EML element to find
Value
the requested element as an EML S4 object
eml_get eml_get
Description
eml_get
eml_get 9
Usage
eml_get(x, element = NULL, ...)
## S4 method for signature 'attributeList'eml_get(x, eml = x)
## S4 method for signature 'unitList'eml_get(x = read_eml(system.file("xsd/eml-2.1.1/eml-unitDictionary.xml",package = "EML")))
Arguments
x an EML object or child/descendant object
element name of the element to be extracted. If multiple occurrences are found, willextract all
... additional arguments for specific get_* methods, see details
eml the eml file from which to look up references (optional)
Details
Some elements have custom get_<class> functions which return the requested metadata in a morenatural format, such as get_attributeList, which returns data.frames containing the desired meta-data. If such a function exists for the element requested, that function is called instead. Addi-tional arguments given to ‘eml_get‘ will be passed to that function via ..., for example, compareget_attributes to the example shown here.
Methods (by class)
• attributeList: get method for attributeList
• unitList: get method for UnitList
Examples
f <- system.file("xsd/test", "eml-datasetWithUnits.xml", package = "EML")eml <- read_eml(f)eml_get(eml, "physical")eml_get(eml, "attributeList")
## The first argument need not be an "eml" class, it could be a child element; e.g.eml_get(eml@dataset@dataTable, "physical")
10 eml_validate
eml_locate_schema eml_locate_schema
Description
eml_locate_schema returns the location of the XSD schema file for a given EML document, asshipped with the EML R package.
Usage
eml_locate_schema(eml, ns = NA)
Arguments
eml an xml2::xml_document instance for an EML document
ns the namespace URI for the top (root) element
Details
The schema location is based on the last path component from the EML namespace (e.g., eml-2.1.1), which corresponds to the directory containing xsd files that ship with the EML package.Schema files are copies of the schemas from the EML versioned releases. If an appropriate schemais not found, the function returns FALSE.
Value
fully qualified path to the XSD schema for the appropriate version of EML
Examples
f <- system.file("examples", "example-eml-2.1.1.xml", package = "EML")eml <- xml2::read_xml(f)schema <- eml_locate_schema(eml)
eml_validate eml_validate
Description
eml_validate processes an EML document using the XSD schema for the appropriate version ofEML and determines if the document is schema-valid as defined by the XSD specification
Usage
eml_validate(eml, encoding = "UTF-8", schema = NULL)
eml_view 11
Arguments
eml an eml class object, file, or xml document
encoding optional, if eml is a file path / an eml and has special characters, one can givesthe encoding used by xmlParse.
schema path to schema
... additional arguments to eml_write, such as namespaces
Value
Whether the document is valid (logical)
Examples
f <- system.file("xsd/test", "eml.xml", package = "EML")
## validate given a file name, without needing to parse firsteml_validate(f)
## Validate given an "eml" objecteml <- read_eml(f)eml_validate(eml)
eml_view View an EML
Description
View an EML
Usage
eml_view(eml_path, ...)
Arguments
eml_path Path to the EML one wants to view
... additional arguments to read_xml
Details
The function needs the listviewer package which you can install from CRAN via install.packages("listviewer")).The function uses listviewer::jsonedit which gives a crude but useful viewing of the EML
12 get_attributes
Value
Nothing, the EML is viewed in the Viewer.
Examples
f <- system.file("xsd/test", "eml-datasetWithUnits.xml", package = "EML")eml_view(f)f <- system.file("xsd/test", "eml.xml", package = "EML")eml_view(f)f <- system.file("xsd/test", "eml-sample.xml", package = "EML")eml_view(f)f <- system.file("xsd/test", "eml-datasetWithCitation.xml", package = "EML")eml_view(f)f <- system.file("examples", "example-eml-2.1.0.xml", package = "EML")eml_view(f)
get_attributes get_attributes
Description
get_attributes
Usage
get_attributes(x, eml = x)
Arguments
x an "attributeList" element from EML
eml The full eml document, needed only if <references> outside of attributes mustbe resolved.
Details
EML metadata can use "references" elements which allow one attribute to use metadata declaredelsewhere in the document. This function will automatically resolve these references and thus inferthe correct metadata.
Value
a data frame whose rows are the attributes (names of each column in the data file) and whosecolumns describe metadata about those attributes. By default separate tables are given for each type
get_taxonomicCoverage 13
Examples
# runs > 5s
eml <- read_eml(system.file("xsd/test/eml-datasetWithAttributelevelMethods.xml", package = "EML"))get_attributes( eml@dataset@dataTable[[1]]@attributeList )
get_taxonomicCoverage get_taxonomicCoverage
Description
get_taxonomicCoverage
Usage
get_taxonomicCoverage(taxonomicCoverage)
Arguments
taxonomicCoverage
a taxonomicCoverage class object
Details
extract information from a taxonomicCoverage object and construct a data frame
Value
a data frame with rank names as column names
Examples
f <- system.file("xsd/test/eml-i18n.xml", package="EML")eml <- read_eml(f)df <- get_taxonomicCoverage(eml@dataset@coverage@taxonomicCoverage)
14 get_TextType
get_TextType get_TextType
Description
Render a TextType node int HTML or some other format
Usage
get_TextType(node, to = "html", output = tempfile(class(node), fileext =paste0(".", to)), view = TRUE)
Arguments
node any TextType node
to desired format, default is html, but can be any type supported by pandoc (docx,md, etc)
output name of the desired output file
view if HTML, do we want to open result in browser?
Value
creates a file requested.
Examples
## Convert an EML abstract to markdownf <- system.file("examples/hf205.xml", package = "EML")eml <- read_eml(f)abstract <- eml_get(eml, "abstract")get_TextType(abstract[[1]], "markdown", "abstract.markdown")readLines("abstract.markdown")unlink("abstract.markdown") # tidy up
## Turn a docx file into EML abstract and preview at HTMLf <- system.file("examples/hf205-abstract.docx", package = "EML")a <- as(set_TextType(f), "abstract")get_TextType(a)
get_unitList 15
get_unitList get_unitList
Description
get_unitList
Usage
get_unitList(x = read_eml(system.file("xsd/eml-2.1.1/eml-unitDictionary.xml",package = "EML")))
Arguments
x a unitList object. Usually found in eml@additionalMetadata[[1]]@metadata,see details
Details
If no unitList is provided, the function reads in the eml-unitDictionary defining all standard unitsand unitTypes. This provides a convenient way to look up standard units and their EML-recognizednames when defining metadata, e.g. in the table passed to ‘set_attributes()‘.
Value
a list with two data.frames: "units", a table defining unit names, types, and conversions to SI, and"unitTypes", defining the type of unit. For instance, the unit table could define "Hertz" as a unit ofunitType frequency, and the unitType define frequency as a type whose dimension is 1/time.
Examples
# Read in additional units defined in a EML file
f <- system.file("xsd/test/eml-datasetWithUnits.xml", package = "EML")eml <- read_eml(f)unitList <- get_unitList(eml@additionalMetadata[[1]]@metadata)
## Read in the definitions of standard units:get_unitList()
16 read_eml
is_standardUnit is_standardUnit
Description
is_standardUnit
Usage
is_standardUnit(x)
Arguments
x name of unit to check
Value
TRUE if unit is exact match to the id of a unit in the Standard Units Table, FALSE otherwise.
Examples
is_standardUnit("amperePerMeter") # TRUEis_standardUnit("speciesPerSquareMeter") # FALSE
read_eml read_eml
Description
read_eml
Usage
read_eml(file, ...)
Arguments
file path to an EML file... additional arguments to read_xml
Value
an eml object (S4 object)
Examples
f <- system.file("xsd/test", "eml.xml", package = "EML")eml <- read_eml(f)
set_attributes 17
set_attributes set_attributes
Description
set_attributes
Usage
set_attributes(attributes, factors = NULL, col_classes = NULL)
Arguments
attributes a joined table of all attribute metadata (such as returned by get_attributes,see details)
factors a table with factor code-definition pairs; see details
col_classes optional, list of R column classes (’ordered’, ’numeric’, ’factor’, ’Date’, or’character’, case sensitive) will let the function infer missing ’domain’ and ’mea-surementScale’ values for attributes column. Should be in same order as at-tributeNames in the attributes table, or be a named list with names correspondingto attributeNames in the attributes table.
Details
The attributes data frame must use only the recognized column headers shown here. The attributesdata frame must contain columns for required metadata. These are:
For all data: - attributeName (required, free text field) - attributeDefinition (required, free text field)- measurementScale (required, "nominal", "ordinal", "ratio", "interval", or "dateTime", case sensi-tive) but it can be inferred from col_classes. - domain (required, "numericDomain", "textDomain","enumeratedDomain", or "dateTimeDomain", case sensitive) but it can be inferred from col_classes.
For numeric (ratio or interval) data: - unit (required)
For character (textDomain) data: - definition (required)
For dateTime data: - formatString (required)
For factor data:
Value
an eml "attributeList" object
18 set_coverage
set_coverage set_coverage
Description
set_coverage
Usage
set_coverage(beginDate = character(), endDate = character(),date = character(), sci_names = character(),geographicDescription = character(), westBoundingCoordinate = numeric(),eastBoundingCoordinate = numeric(), northBoundingCoordinate = numeric(),southBoundingCoordinate = numeric(), altitudeMinimum = numeric(),altitudeMaximum = numeric(), altitudeUnits = character())
Arguments
beginDate Starting date for temporal coverage range.endDate End date for temporal coverage rangedate give a single date, or vector of single dates covered (instead of beginDate and
endDate)sci_names string (space seperated) or list or data frame of scientific names for species cov-
ered. See detailsgeographicDescription
text string describing the geographic locationwestBoundingCoordinate
Decimal longitude for west edge bounding boxeastBoundingCoordinate
Decimal longitude for east edge bounding boxnorthBoundingCoordinate
Decimal latitude value for north of bounding boxsouthBoundingCoordinate
Decimal latitude value for south edge of bounding boxaltitudeMinimum
minimum altitude covered by the data (optional)altitudeMaximum
maximum altitude covered by the data (optional)altitudeUnits name of the units used to measure altitude, if given
Details
set_coverage provides a simple and concise way to specify most common temporal, taxonomic, andgeographic coverage metadata. For certain studies this will not be well suited, and users will needthe more flexible but more verbose construction using "new()" methods; for instance, to specifytemporal coverage in geological epoch instead of calendar dates, or to specify taxonomic coveragein terms of other ranks or identifiers.
set_methods 19
Value
a coverage object for EML
Note
If "sci_names" is a data frame, column names of the data frame are rank names. For user-defined"sci_names", users must make sure that the order of rank names they specify is from high to low.Ex. "Kingdom","Phylum","Class","Order","Family","Genus","Species","Common"
Examples
coverage <-set_coverage(begin = '2012-06-01', end = '2013-12-31',
sci_names = "Sarracenia purpurea",geographicDescription = "California coast, down through Baja, Mexico",west = -122.44, east = -117.15,north = 37.38, south = 30.00)
set_methods set_methods
Description
set_methods
Usage
set_methods(methods_file, instrumentation = character(),software = new("software"), sampling_file = NULL,sampling_coverage = new("coverage"), sampling_citation = new("citation"),qualityControl_file = NULL)
Arguments
methods_file Path to a file (markdown or .docx) containing a description of the methods usedinstrumentation
optional, text describing instrumentation used in methods
software optional, an EML software node describing software used in methods
sampling_file optional, Path to a file (.md or .docx) describing sampling methodsampling_coverage
optional, coverage node for methods, e.g. set_coverage()sampling_citation
optional, a citation element describing the sampling protocolqualityControl_file
optional, path to a file (.md or .docx) describing quality control methods
20 set_physical
Value
A methods object
Examples
f <- system.file("examples/hf205-methods.md", package = "EML")set_methods(methods_file = f)
## Can also import from methods written in a .docx MS Word file.f <- system.file("examples/hf205-methods.docx", package = "EML")set_methods(methods_file = f)
set_physical set_physical
Description
set_physical
Usage
set_physical(objectName, id = character(), numHeaderLines = character(),numFooterLines = character(), recordDelimiter = "\\n\\r",fieldDelimiter = ",", collapseDelimiters = logical(),literalCharacter = character(), quoteCharacter = character(),attributeOrientation = "column", size = character(), sizeUnit = "bytes",authentication = character(), authMethod = character(),characterEncoding = character(), encodingMethod = character(),compressionMethod = character(), url = character())
Arguments
objectName name for the object, usually a filename like "hf205-1.csv"
id optional, an id value for the <physical> element in EML, for use in referencing
numHeaderLines Number of header lines preceding data. Lines are determined by the physicalL-ineDelimiter, or if it is absent, by the recordDelimiter. This value indicated thenumber of header lines that should be skipped before starting to parse the data.
numFooterLines Number of footer lines following data. Lines are determined by the physicalL-ineDelimiter, or if it is absent, by the recordDelimiter. This value indicatedthe number of footer lines that should be skipped after parsing the data. If thisvalue is omitted, parsers should assume the data continues to the end of the datastream.
set_physical 21
recordDelimiter
This element specifies the record delimiter character when the format is text.The record delimiter is usually a linefeed (\n) on UNIX, a carriage return (\r) onMacOS, or both (\r\n) on Windows/DOS. Multiline records are usually delimitedwith two line ending characters, for example on UNIX it would be two linefeedcharacters (\n\n). As record delimiters are often non-printing characters, onecan use either the special value "\n" to represent a linefeed (ASCII 0x0a) and"\r" to represent a carriage return (ASCII 0x0d). Alternatively, one can use thehex value to represent character values (e.g., 0x0a).
fieldDelimiter "," character by default (for csv files). This element specifies a character to beused in the object for indicating the ending column for an attribute. The delim-iter character itself is not part of the attribute value, but rather is present in thecolumn following the last character of the value. Typical delimiter charactersinclude commas, tabs, spaces, and semicolons. The only time the fieldDelim-iter character is not interpreted as a delimiter is if it is contained in a quotedstring (see quoteCharacter) or is immediately preceded by a literalCharacter.Non-printable quote characters can be provided as their hex values, and for tabcharacters by its ASCII string "\t". Processors should assume that the field startsin the column following the previous field if the previous field was fixed, or inthe column following the delimiter from the previous field if the previous fieldwas delimited.
collapseDelimiters
The collapseDelimiters element specifies whether sequential delimiters shouldbe treated as a single delimiter or multiple delimiters. An example is when aspace delimiter is used; often there may be several repeated spaces that shouldbe treated as a single delimiter, but not always. The valid values are yes or no.If it is set to yes, then consecutive delimiters will be collapsed to one. If set tono or absent, then consecutive delimiters will be treated as separate delimiters.Default behaviour is no; hence, consecutive delimiters will be treated as separatedelimiters, by default.
literalCharacter
This element specifies a character to be used for escaping special character val-ues so that they are treated as literal values. This allows "escaping" for specialcharacters like quotes, commas, and spaces when they are intended to be used inan attribute value rather than being intended as a delimiter. The literalCharacteris typically a \.
quoteCharacter This element specifies a character to be used in the object for quoting values sothat field delimiters can be used within the value. This basically allows delimiter"escaping". The quoteChacter is typically a " or ’. When a processor encountersa quote character, it should not interpret any following characters as a delimiteruntil a matching quote character has been encountered (i.e., quotes come inpairs). It is an error to not provide a closing quote before the record ends. Non-printable quote characters can be provided as their hex values.
attributeOrientation
Specifies whether the attributes described in the physical stream are found incolumns or rows. The valid values are column or row. If set to ’column’, thenthe attributes are in columns. If set to ’row’, then the attributes are in rows. Roworientation is rare.
22 set_taxonomicCoverage
size This element contains information of the physical size of the entity, by defaultrepresented in bytes unless the sizeUnit attribute is provided to change the units.
sizeUnit the unit in which size is measured; default is ’bytes’
authentication This element describes authentication procedures or techniques, typically bygiving a checksum value for the object. The method used to compute the au-thentication value (e.g., MD5) is listed in the method attribute.
authMethod the method for authentication checksum, e.g. MD5characterEncoding
This element contains the name of the character encoding. This is typicallyASCII or UTF-8, or one of the other common encodings.
encodingMethod This element lists a encoding method used to encode the object, such as base64,BinHex.
compressionMethod
This element lists a compression method used to compress the object, such aszip, compress, etc. Compression and encoding methods must be listed in theorder in which they were applied, so that decompression and decoding shouldoccur in the reverse order of the listing. For example, if a file is compressedusing zip and then encoded using MIME base64, the compression method wouldbe listed first and the encoding method second.
url optional. The complete url from which the data file can be downloaded, if pos-sible.
Value
an EML physical object, such as used in a dataTable element to define the format of the data file.
Examples
set_physical("hf205-01-TPexp1.csv")
set_taxonomicCoverage set_taxonomicCoverage
Description
set_taxonomicCoverage
Usage
set_taxonomicCoverage(sci_names)
Arguments
sci_names string (space seperated) or list or data frame of scientific names for species cov-ered.
set_TextType 23
Details
Turn a data.frame or a list of scientific names into a taxonomicCoverage block sci_names can bea space-separated character string or a data frame with column names as rank name or a list ofuser-defined taxonomicClassification
Value
a taxonomicCoverage object for EML
Note
If "sci_names" is a data frame, column names of the data frame are rank names. For user-defined"sci_names", users must make sure that the order of rank names they specify is from high to low.Ex. "Kingdom","Phylum","Class","Order","Family","Genus","Species","Common"
Examples
taxon_coverage <-set_taxonomicCoverage(list(KINGDOM="Plantae",
PHYLUM="Phaeophyta",CLASS="Phaeophyceae",ORDER="Laminariales",FAMILY="Lessoniaceae",GENUS="Macrocystis",genusSpecies="Macrocystis pyrifera",commonName="MAPY"))
df <- data.frame(KINGDOM="Plantae",PHYLUM="Phaeophyta",CLASS="Phaeophyceae",ORDER="Laminariales",FAMILY="Lessoniaceae",GENUS="Macrocystis",genusSpecies="Macrocystis pyrifera",commonName="MAPY")
taxon_coverage <- set_taxonomicCoverage(df)
set_TextType set_TextType
Description
For any EML element of class TextType, this function can be used to generate the appropriate EMLfrom a markdown-formatted file.
Usage
set_TextType(file = NULL, text = NULL)
24 set_unitList
Arguments
file path to a file providing formatted input text, see details.
text a plain text character string which will be used directly as the content of the nodeif no file is given
Details
If the ‘rmarkdown‘ package is installed, then the input file can be a Microsoft Word (.docx) file,a markdown file, or other file recognized by Pandoc (see http://pandoc.org), which will automatethe conversion to a docbook. Otherwise, the input file should already be in docbook format (with.xml or .dbk extension). Note that pandoc comes pre-installed in RStudio and is required for thermarkdown package.
Value
a TextType object that can be coerced into any element inheriting from TextType, see examples
Examples
## using a simple character stringa <- set_TextType(text = "This is the abstract")as(a, "abstract")
## Using an external markdown filef <- system.file("examples/hf205-abstract.md", package = "EML")a <- set_TextType(f)as(a, "abstract")
## Can also import from methods written in a .docx MS Word file.f <- system.file("examples/hf205-abstract.docx", package = "EML")a <- set_TextType(f)as(a, "abstract")
## Documents with title headings use `section` instead of `para` notationf <- system.file("examples/hf205-methods.docx", package = "EML")d <- set_TextType(f)as(d, "description")
set_unitList set_unitList
set_unitList 25
Description
Define custom units, including new unitTypes. Note that it is not necessary to define most commonunits, see get_unitList to display standard units or parse other custom unitList files.
Usage
set_unitList(units, unitTypes = NULL, as_metadata = FALSE)
Arguments
units a data.frame describing the custom units, see details.
unitTypes optional, a data.frame defining any additional unitTypes not already defined
as_metadata logical, default FALSE. If true, returns an ‘additionalMetadata‘ element, seebelow.
Details
The units data.frame must have the following columns: - id: the referenced name of unit (singular).e.g. ’meter’, ’second’ - unitType: the base type of unit, e.g. ’length’. If not from a standard type,a new unitType must be provided - multiplierToSI: the multiplicative constant to convert to the SIunit. - parentSI: the name of the parent SI unit, e.g. second. - description: a text string describingthe unit of measure. The following columns are optional: - name: usually the same as the id of theunit, e.g. second - abbreviation: common abbreviation, e.g. s - constantToSI: an additive constantto convert to the equivalent SI unit. If not given, default is "0"
In practice, researchers may save these tables of custom units they frequently use in an external .csvor other format and read them in to R for ready re-use.
The unitType table must have the following columns: - id: the name by which the unitType isreferred to. - name: optional, default is same as the id - dimension: name of a base dimension ofthe unit - power: the power to which the dimension is raised (NA implies power of 1)
Value
By default the function returns an S4 unitList object, like other set_ methods. If as_metadata is setto TRUE, function returns an ‘additionalMetadata‘ element, which can be added directly to an emlobject (see examples), which is the usual location for declaring additional units.
Note that EML permits a metadata element to contain arbitrary XML, including but not limited tounitList XML for custom units (which is really part of the stmml unit vocabulary used by EML, butpart of a more general standard.) This means that once converted to a metadata element, the unitlist is coerced into stmml XML and can no longer be subset or modified in the same way.
Examples
## create the "unitType" table for custom unitid = c("speed", "speed", "acceleration", "acceleration", "frequency")dimension = c("length", "time", "length", "time", "time")power = c(NA, "-1", NA, "-2", "-1")unitTypes <- data.frame(id = id, dimension = dimension,
26 write_eml
power = power, stringsAsFactors = FALSE)
## Create the units tableid = c("minute", "centimeter")unitType = c("time", "length")parentSI = c("second", "meter")multiplierToSI = c("0.0166", "1")description = c("one minute is 60 seconds", "centimeter is a 100th of a meter")units = data.frame(id = id, unitType = unitType, parentSI = parentSI,
multiplierToSI = multiplierToSI, description = description,stringsAsFactors = FALSE)
unitList <- set_unitList(units, unitTypes)
## reverse operation also works:get_unitList(unitList)
## To add this to an EML document:new("eml", additionalMetadata = as(unitList, "additionalMetadata"))
## Equivalently:additionalMetadata <- set_unitList(units, unitTypes, as_metadata = TRUE)new("eml", additionalMetadata = additionalMetadata)
write_eml write_eml
Description
write_eml
Usage
write_eml(eml, file, namespaces = NULL, ns = "eml", ...)
Arguments
eml an eml class object
file file name to write XML.
namespaces named character vector of additional XML namespaces to use.
ns root namespace abbreviation
... additional arguments to write_xml
Value
If file is not specified, the result is a character string containing the resulting XML content. Other-wise return silently.
write_eml 27
Examples
f <- system.file("examples", "example-eml-valid.xml", package = "EML")eml <- read_eml(f)write_eml(eml, "test.xml")unlink("test.xml") # clean up
Index
c,additionalInfo-method(c,section-method), 2
c,additionalMetadata-method(c,section-method), 2
c,address-method (c,section-method), 2c,allow-method (c,section-method), 2c,alternateIdentifier-method
(c,section-method), 2c,altitudeResolution-method
(c,section-method), 2c,associatedParty-method
(c,section-method), 2c,attribute-method (c,section-method), 2c,attributeLabel-method
(c,section-method), 2c,attributeReference-method
(c,section-method), 2c,authentication-method
(c,section-method), 2c,bandDescription-method
(c,section-method), 2c,bounds-method (c,section-method), 2c,changeHistory-method
(c,section-method), 2c,citation-method (c,section-method), 2c,citetitle-method (c,section-method), 2c,classificationSystem-method
(c,section-method), 2c,codeDefinition-method
(c,section-method), 2c,codesetURL-method (c,section-method),
2c,commonName-method (c,section-method),
2c,compressionMethod-method
(c,section-method), 2c,constraint-method (c,section-method),
2c,contact-method (c,section-method), 2
c,controlPoint-method(c,section-method), 2
c,cornerPoint-method(c,section-method), 2
c,coverage-method (c,section-method), 2c,creator-method (c,section-method), 2c,datasetGPolygon-method
(c,section-method), 2c,datasetGPolygonExclusionGRing-method
(c,section-method), 2c,dataSource-method (c,section-method),
2c,dataTable-method (c,section-method), 2c,deliveryPoint-method
(c,section-method), 2c,deny-method (c,section-method), 2c,depthResolution-method
(c,section-method), 2c,describes-method (c,section-method), 2c,description-method
(c,section-method), 2c,descriptor-method (c,section-method),
2c,descriptorValue-method
(c,section-method), 2c,dimension-method (c,section-method), 2c,distribution-method
(c,section-method), 2c,editor-method (c,section-method), 2c,electronicMailAddress-method
(c,section-method), 2c,emphasis-method (c,section-method), 2c,encodingMethod-method
(c,section-method), 2c,enumeratedDomain-method
(c,section-method), 2c,fieldDelimiter-method
(c,section-method), 2c,geographicCoverage-method
28
INDEX 29
(c,section-method), 2c,geometry-method (c,section-method), 2c,givenName-method (c,section-method), 2c,gRingPoint-method (c,section-method),
2c,horizCoordSysDef-method
(c,section-method), 2c,identificationReference-method
(c,section-method), 2c,identifierName-method
(c,section-method), 2c,implementation-method
(c,section-method), 2c,individualName-method
(c,section-method), 2c,institution-method
(c,section-method), 2c,instrumentation-method
(c,section-method), 2c,itemizedlist-method
(c,section-method), 2c,keyword-method (c,section-method), 2c,keywordSet-method (c,section-method),
2c,license-method (c,section-method), 2c,licenseURL-method (c,section-method),
2c,listitem-method (c,section-method), 2c,literalCharacter-method
(c,section-method), 2c,literalLayout-method
(c,section-method), 2c,machineProcessor-method
(c,section-method), 2c,mediumFormat-method
(c,section-method), 2c,metadataProvider-method
(c,section-method), 2c,methodStep-method (c,section-method),
2c,missingValueCode-method
(c,section-method), 2c,onlineUrl-method (c,section-method), 2c,operatingSystem-method
(c,section-method), 2c,orderedlist-method
(c,section-method), 2c,organizationName-method
(c,section-method), 2c,originator-method (c,section-method),
2c,otherEntity-method
(c,section-method), 2c,para-method (c,section-method), 2c,parameter-method (c,section-method), 2c,parameterDefinition-method
(c,section-method), 2c,pattern-method (c,section-method), 2c,performer-method (c,section-method), 2c,permission-method (c,section-method),
2c,personnel-method (c,section-method), 2c,phone-method (c,section-method), 2c,physical-method (c,section-method), 2c,physicalLineDelimiter-method
(c,section-method), 2c,positionName-method
(c,section-method), 2c,principal-method (c,section-method), 2c,proceduralStep-method
(c,section-method), 2c,programmingLanguage-method
(c,section-method), 2c,protocol-method (c,section-method), 2c,publicationPlace-method
(c,section-method), 2c,qualityControl-method
(c,section-method), 2c,quantitativeAccuracyReport-method
(c,section-method), 2c,quantitativeAttributeAccuracyAssessment-method
(c,section-method), 2c,quoteCharacter-method
(c,section-method), 2c,recipient-method (c,section-method), 2c,recordDelimiter-method
(c,section-method), 2c,referencedEntityId-method
(c,section-method), 2c,relatedProject-method
(c,section-method), 2c,role-method (c,section-method), 2c,salutation-method (c,section-method),
2c,sampling-method (c,section-method), 2c,section-method, 2
30 INDEX
c,singleDateTime-method(c,section-method), 2
c,software-method (c,section-method), 2c,spatialRaster-method
(c,section-method), 2c,spatialVector-method
(c,section-method), 2c,storageType-method
(c,section-method), 2c,storedProcedure-method
(c,section-method), 2c,subscript-method (c,section-method), 2c,subStep-method (c,section-method), 2c,superscript-method
(c,section-method), 2c,taxonomicClassification-method
(c,section-method), 2c,taxonomicCoverage-method
(c,section-method), 2c,temporalCoverage-method
(c,section-method), 2c,textDelimited-method
(c,section-method), 2c,textDomain-method (c,section-method),
2c,textFixed-method (c,section-method), 2c,timeScaleCitation-method
(c,section-method), 2c,title-method (c,section-method), 2c,ulink-method (c,section-method), 2c,unit-method (c,section-method), 2c,unitType-method (c,section-method), 2c,userId-method (c,section-method), 2c,value-method (c,section-method), 2c,view-method (c,section-method), 2c,vouchers-method (c,section-method), 2
eml_find, 8eml_get, 8eml_get,attributeList-method (eml_get),
8eml_get,unitList-method (eml_get), 8eml_locate_schema, 10eml_validate, 10eml_view, 11
get_attributes, 9, 12, 17get_taxonomicCoverage, 13get_TextType, 14
get_unitList, 15
is_standardUnit, 16
read_eml, 16read_xml, 11, 16
set_attributes, 17set_coverage, 18set_methods, 19set_physical, 20set_taxonomicCoverage, 22set_TextType, 23set_unitList, 24
write_eml, 26write_xml, 26