which_in_eml: Search through EMLs

Description Usage Arguments Author(s) Examples

View source: R/eml.R

Description

This function returns indices within an EML list that contain an instance where test == TRUE. See examples for more information.

Usage

1
which_in_eml(eml_list, element, test)

Arguments

eml_list

(S4/List) an EML list object

element

(character) element to evaluate

test

(function/character) A function to evaluate (see examples). If test is a character, will evaluate if element == test (see example 1).

Author(s)

Mitchell Maier [email protected]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
# Question: Which creators have a surName "Smith"?
n <- which_in_eml(eml@dataset@creator, "surName", "Smith")
# Answer: [email protected]@creator[n]

# Question: Which dataTables have an entityName that begins with "2016"
n <- which_in_eml(eml@dataset@dataTable, "entityName", function(x) {grepl("^2016", x)})
# Answer: [email protected]@dataTable[n]

# Question: Which attributes in dataTable[[1]] have a numberType "natural"?
n <- which_in_eml(eml@dataset@dataTable[[1]]@attributeList@attribute, "numberType", "natural")
# Answer: [email protected]@dataTable[[1]]@[email protected][n]

#' # Question: Which dataTables have at least one attribute with a numberType "natural"?
n <- which_in_eml(eml@dataset@dataTable, "numberType", function(x) {"natural" %in% x})
# Answer: [email protected]@dataTable[n]

## End(Not run)

NCEAS/arcticdatautils documentation built on Oct. 11, 2018, 11:13 a.m.