Title: | Domain Specific MetaData Scheme |
---|---|
Description: | Forms the core for developing own domain specific metadata schemes. It contains the basic functionality needed for all metadata schemes based on the 'dmdScheme'. See R.M. Krug and O.L. Petchey (2019) <DOI:10.5281/zenodo.3581970>. |
Authors: | Rainer M. Krug [aut, cre] , Owen L. Petchey [ctb] |
Maintainer: | Rainer M. Krug <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3.5 |
Built: | 2024-11-17 03:40:08 UTC |
Source: | https://github.com/UZH-PEG/dmdScheme |
x
into a new object of class dmdScheme...
Generic function to convert the data stored in the object x
into a new object of class dmdScheme...
as_dmdScheme(x, keepData = FALSE, ..., verbose = FALSE) ## S3 method for class 'dmdSchemeData_raw' as_dmdScheme( x, keepData = TRUE, convertTypes = TRUE, warnToError = TRUE, checkVersion = TRUE, ..., verbose = FALSE ) ## S3 method for class 'dmdSchemeSet_raw' as_dmdScheme( x, keepData = FALSE, warnToError = TRUE, convertTypes = TRUE, checkVersion = TRUE, ..., verbose = FALSE ) ## S3 method for class 'xml_document' as_dmdScheme(x, keepData = TRUE, useSchemeInXml = NULL, ..., verbose = FALSE)
as_dmdScheme(x, keepData = FALSE, ..., verbose = FALSE) ## S3 method for class 'dmdSchemeData_raw' as_dmdScheme( x, keepData = TRUE, convertTypes = TRUE, warnToError = TRUE, checkVersion = TRUE, ..., verbose = FALSE ) ## S3 method for class 'dmdSchemeSet_raw' as_dmdScheme( x, keepData = FALSE, warnToError = TRUE, convertTypes = TRUE, checkVersion = TRUE, ..., verbose = FALSE ) ## S3 method for class 'xml_document' as_dmdScheme(x, keepData = TRUE, useSchemeInXml = NULL, ..., verbose = FALSE)
x |
object to be converted |
keepData |
if the data should be kept or replaced with one row with NAs |
... |
additional arguments for methods |
verbose |
give verbose progress info. Useful for debugging. |
convertTypes |
if |
warnToError |
if |
checkVersion |
if |
useSchemeInXml |
if |
dmdScheme as object of class dmdScheme_set
as_dmdScheme(dmdScheme_raw(), keepData = TRUE) as_dmdScheme(dmdScheme_raw()$Experiment) xml <- as_xml(dmdScheme_example()) x <- as_dmdScheme(xml) all.equal(dmdScheme_example(), x)
as_dmdScheme(dmdScheme_raw(), keepData = TRUE) as_dmdScheme(dmdScheme_raw()$Experiment) xml <- as_xml(dmdScheme_example()) x <- as_dmdScheme(xml) all.equal(dmdScheme_example(), x)
x
into a new object of class dmdScheme_raw...
Generic function to convert the data stored in the object x
into a new object of class dmdScheme_raw...
as_dmdScheme_raw(x, ...) ## S3 method for class 'dmdSchemeData' as_dmdScheme_raw(x, ...) ## S3 method for class 'dmdSchemeSet' as_dmdScheme_raw(x, ...) ## S3 method for class 'xml_document' as_dmdScheme_raw(x, useSchemeInXml = NULL, ...)
as_dmdScheme_raw(x, ...) ## S3 method for class 'dmdSchemeData' as_dmdScheme_raw(x, ...) ## S3 method for class 'dmdSchemeSet' as_dmdScheme_raw(x, ...) ## S3 method for class 'xml_document' as_dmdScheme_raw(x, useSchemeInXml = NULL, ...)
x |
object to be converted |
... |
additional arguments for methods |
useSchemeInXml |
if |
dmdScheme as object of class dmdScheme_raw
as_dmdScheme_raw(dmdScheme(), keepData = TRUE)
as_dmdScheme_raw(dmdScheme(), keepData = TRUE)
Generic function to convert an object to an object which can be saved as EML
as_eml(x, ...) ## Default S3 method: as_eml(x, ...)
as_eml(x, ...) ## Default S3 method: as_eml(x, ...)
x |
object to be converted. |
... |
additional arguments for methods |
A list
object which can be converted to EML. It can be
written to a file using write_eml()
. The resulting eml file can be
validated using eml_validate()
.
NB: This does only validate the EML format, and NOT the validation as defined in the scheme definition package!
Generic function to convert an object to xml
as_xml(x, output = "metadata", ...) ## S3 method for class 'dmdSchemeData' as_xml(x, output = "metadata", ...) ## S3 method for class 'dmdSchemeSet' as_xml(x, output = "metadata", ...)
as_xml(x, output = "metadata", ...) ## S3 method for class 'dmdSchemeData' as_xml(x, output = "metadata", ...) ## S3 method for class 'dmdSchemeSet' as_xml(x, output = "metadata", ...)
x |
object to be converted. |
output |
specifies the content and format of the exported xml.
|
... |
additional arguments for methods |
an xml_document
object
x <- as_xml( dmdScheme_example() ) x ## returns \code{xml_document} object
x <- as_xml( dmdScheme_example() ) x ## returns \code{xml_document} object
Generic function to convert an object to a list containing xml(s)
as_xml_list(x, output = "metadata", ...) ## S3 method for class 'dmdSchemeSet' as_xml_list(x, output = "metadata", ...)
as_xml_list(x, output = "metadata", ...) ## S3 method for class 'dmdSchemeSet' as_xml_list(x, output = "metadata", ...)
x |
object to be converted. |
output |
specifies the content and format of the exported xml.
|
... |
additional arguments for methods |
a list()
where each element is xml_document
object
x <- as_xml_list( dmdScheme_example() ) x ## returns a \code{list()} with one \code{xml_document} object
x <- as_xml_list( dmdScheme_example() ) x ## returns a \code{list()} with one \code{xml_document} object
If the cache folder does not exist, and createPermanent = FALSE
, a temporary location is used. To make the cache permanent, call
cache(..., delete = FALSE, createPermanent = FALSE)
cache(..., delete = FALSE, createPermanent = FALSE)
... |
sub caches |
delete |
if |
createPermanent |
if |
cache(createPermanent = TRUE)
and restart your R session.
fully qualified path to the cache folder
Copied from tibble:::cat_line()
cat_ln(...)
cat_ln(...)
... |
will be handed over to |
dmdSchemeSet
containing the authorative definition of the dmdScheme.The dataset contains the authorative definition of the dmdScheme. It contains no data, except one row NA
.
There are two S3 classes defined and used:
dmdSchemeData
: a data.frame
with the class dmdSchemeData
.
Each column is one property of the metadata. It has the following attributes:
name of the data. In the spreadsheet, it is in the cell below (in the Experiment tab) or to the right (other tabs).
the unit of the data in each column.
the type of the data in the column. These will be validated in the validate
function. See there for details.
suggested values for the data of each column. These will be validated in the validate
function. See there for details.
allowed values for the data of each column. These will be validated in the validate
function. See there for details.
general description of the columns.
the names of the columns.
dmdSchemeSet:
a list
with where each element is a dmdSchemeData
object with additional attributes:
name of the dmdScheme used. In the spreadsheet, it is in the cell H1 in ther in the Experiment tab (DATA dmeScheme v0.9.9.)
version of the dmdScheme used. In the spreadsheet, it is in the cell H1 in ther in the Experiment tab (DATA dmeScheme v0.9.9.)
the names of the dmdSchemeData
sets. In the spreadsheet, the names of the tabs.
dmdScheme()
dmdScheme()
dmdScheme()
dmdScheme()
dmdSchemeSet
containing example data.The dataset contains example data. It was created by using the code below.
dmdScheme_example()
dmdScheme_example()
dmdScheme_example()
dmdScheme_example()
dmdScheme_raw
containing the raw data as read in.The dataset contains raw data. An object of class dmdScheme_raw
is
returned by the function read_excel_raw
with the argument
raw = TRUE
and read_excel_raw
. It is usually an
intermediate object, as in the normal workflow, this object is automatically
converted to an object of class dmdSchemeSet
.
dmdScheme_raw()
dmdScheme_raw()
dmdSchemeData_raw
: a data.frame
as returned by the function read_excel
with the class dmdSchemeData_raw
dmdSchemeSet_raw:
a list
with where each element is a dmdSchemeData_raw
object with additional attributes:
name of the dmdScheme for which this object contains the raw data. In the spreadsheet, it is in the cell H1 in ther in the Experiment tab (DATA dmeScheme v0.9.9.)
version of the dmdScheme used. In the spreadsheet, it is in the cell H1 in ther in the Experiment tab (DATA dmeScheme v0.9.9.)
the names of the dmdSchemeData_raw
sets. In the spreadsheet, the names of the tabs.
dmdScheme_raw()
dmdScheme_raw()
Loads fn_org)
, formats it and saves it as fn_new
.
format_dmdScheme_xlsx(fn_org, fn_new, keepData = TRUE)
format_dmdScheme_xlsx(fn_org, fn_new, keepData = TRUE)
fn_org |
file name of the original excel file to be formated |
fn_new |
file name where the final xlsx should be saved to. If missing, it will not be saved. |
keepData |
if |
invisibly the workbook as a workbook object as created by xlsx.crerateWorkbook()
For a detailed explanation of these tokens see the vignette Create and
Customize the index Template
.
lookup_tokens(tokens, scheme, author = "")
lookup_tokens(tokens, scheme, author = "")
tokens |
a character vector containing tokens. These can be enclosed in |
scheme |
a |
author |
the author of the index document |
a list of the length of the input vector tokens
containing the objects returned by the tokens. Null if the tokens contains
invalid values.
lookup_tokens( tokens = c( "%%Treatments.*.2%%", "%%Experiment.*.*%%", "Measurement.method.3" ), scheme = dmdScheme_example(), )
lookup_tokens( tokens = c( "%%Treatments.*.2%%", "%%Experiment.*.*%%", "Measurement.method.3" ), scheme = dmdScheme_example(), )
Each package based on a dmdScheme
can contain examples. This function is the interface to these examples.
In the package dmdScheme
, no examples are included.
The function has two basic usages:
by using make_example(schemeName = "NameOfTheScheme")
all included
examples are listed
by using make_example(name = "basic", schemeName = "NameOfTheScheme")
it will create the example named basic
in a
subdirectory in the current working directory. An existing directory with
the same name, will nod be overwritten!
make_example(name)
make_example(name)
name |
name of the example |
The examples have to be located in a directory called example_data
.
The function is doing two things:
Copying the complete directory from the example_data
directory
to the current working directory
running knitr::purl
on all ./code/*.Rmd
to extract the code into .R
script files. If you want to include an RMarkdown files in the ./code
directory from thisa, use the .rmd
extension (small letters).
invisibly NULL
make_example() ## Not run: make_example("basic") ## End(Not run)
make_example() ## Not run: make_example("basic") ## End(Not run)
index.md
file to accompany the data
deposit packageGeneric function to create the index.md
file to accompany the data
deposit package
Title
make_index( scheme, path = ".", overwrite = FALSE, template = scheme_path_index_template(), author = NULL, make = c("html", "pdf"), pandoc_bin = "pandoc", pandoc_args = "-s", ... ) ## S3 method for class 'dmdSchemeSet' make_index( scheme, path = ".", overwrite = FALSE, template = scheme_path_index_template(), author = NULL, make = c("pdf", "html"), pandoc_bin = "pandoc", pandoc_args = "-s", ... )
make_index( scheme, path = ".", overwrite = FALSE, template = scheme_path_index_template(), author = NULL, make = c("html", "pdf"), pandoc_bin = "pandoc", pandoc_args = "-s", ... ) ## S3 method for class 'dmdSchemeSet' make_index( scheme, path = ".", overwrite = FALSE, template = scheme_path_index_template(), author = NULL, make = c("pdf", "html"), pandoc_bin = "pandoc", pandoc_args = "-s", ... )
scheme |
a dmdScheme from which the values for the tokens in the
|
path |
path to where the 'index' should be created. The file name of the created index is identical to the file name of the template. |
overwrite |
if TRUE, the target index file will be overwritten automatically, unless the target index is equal to the template, in which case, an error would be raised in all cases. |
template |
template to be used for the index file. For details see the
vignette Create and Customize the index template. The default
template is at |
author |
of the index file |
make |
character vector containing types into which the generated index file should be converted to. default is html and pdf. This function uses pandoc for the conversion!. |
pandoc_bin |
pandoc executable. Needs fully qualified path when not in
|
pandoc_args |
arguments for calling pandoc |
... |
additional arguments for methods |
returns path to the created index.md
file
## Not run: # takes to long for CRAN make_index( dmdScheme_example(), path = tempdir() ) ## End(Not run)
## Not run: # takes to long for CRAN make_index( dmdScheme_example(), path = tempdir() ) ## End(Not run)
This function is not for the user of a scheme, but for the development process of a new scheme.
make_new_package(path = ".")
make_new_package(path = ".")
path |
path where the package should be created. Default is the current working directory. |
A new metadata scheme can be created by using the function
scheme_make
. This function will create a package to add
functionality to the currently used scheme as a package which will depend on
scheme_active()
. This function uses the function package.skeleton()
from the utils
package to create a new directory for the new metadata
scheme, and adds a function aaa.R
which loads the current package
whenever the new package is loaded as well as some fields to the
DESCRIPTION
file.
For a documentation of the workflow to create a new scheme, see the vignette Howto Create a new scheme.
invisibly NULL
make_new_package( path = tempdir() )
make_new_package( path = tempdir() )
dmdScheme_validation
objectCreate new dmdScheme_validation
object
new_dmdScheme_validation()
new_dmdScheme_validation()
new dmdScheme_validation
object
Open system.file(paste0(schemeName, ".xlsx"), package = schemeName)
in excel.
New data can be entered and the file has to be saved at a different location
as it is a read-only file.
open_new_spreadsheet( file = NULL, open = TRUE, keepData = FALSE, format = TRUE, overwrite = FALSE, verbose = FALSE )
open_new_spreadsheet( file = NULL, open = TRUE, keepData = FALSE, format = TRUE, overwrite = FALSE, verbose = FALSE )
file |
if not |
open |
if |
keepData |
if |
format |
if |
overwrite |
if |
verbose |
give verbose progress info. Useful for debugging. |
invisibly the fully qualified path to the file which would have been opened, if open == TRUE
.
## Not run: open_new_spreadsheet(schemeName = "dmdScheme", format = FALSE, verbose = TRUE) ## End(Not run)
## Not run: open_new_spreadsheet(schemeName = "dmdScheme", format = FALSE, verbose = TRUE) ## End(Not run)
Metadata is essential for the managing and archiving of data. Consequentially, metadata schemes, which standardise the property names used in specifying the metadata, play an essential role in this. Nevertheless (or because of this), metadata schemes are usually big, complex, difficult to read and understand, and, in consequence, are not used as often as they should be.
This package provides a framework called dmdScheme
, which
makes it easier to develop a domain specific metadata scheme: by using a spreadsheet as the base for defining the new scheme
provides basic functionality for the new metadata scheme: including entering, validating, exporting and saving of the new metadata
makies it easier to enter new metadata: by uising a spreadsheet to enter the new metadata which can than be imported and exported as xml
This package provides for the creator of a new Domain Specific MetaData Scheme:
a simple way of discussing and developing a new scheme as it is represented in a spreadsheet
a function to create a new R package for a new domain specific metadata scheme which is based on a spreadsheet containing the definition and inherits all the functionality of this package (validation, printing, export, import, ...)
easy update of the new scheme based by re-importing the new version of the scheme from the spreadsheet by simply calling one function
easy extension of the functionality as the whole architecture is based
on S3 methods and the new scheme inherits from the dmdScheme
objects.
This package provides for the user of a Domain Specific MetaData Scheme:
the authorative definition of an example dmdScheme
object definitions for this scheme for R
Excel spreadsheet for entering the metadata for an experiment
functions to validate this metadata
functions to export the metadata to xml files, one per data file
summary
Internal function to ptint dmdScheme_validation of format summary
print_dmdScheme_validation_details( x, level, listLevel, format, error = c(0, 1, 2, 3, NA), ... )
print_dmdScheme_validation_details( x, level, listLevel, format, error = c(0, 1, 2, 3, NA), ... )
x |
as in print.dmdScheme_validation |
level |
as in print.dmdScheme_validation |
listLevel |
as in print.dmdScheme_validation |
format |
as in print.dmdScheme_validation |
error |
numeric v ector, containing error levels to print. Default is all error levels. |
... |
as in print.dmdScheme_validation |
as in print.dmdScheme_validation
summary
Internal function to ptint dmdScheme_validation of format summary
print_dmdScheme_validation_summary( x, level, listLevel, error = c(0, 1, 2, 3, NA) )
print_dmdScheme_validation_summary( x, level, listLevel, error = c(0, 1, 2, 3, NA) )
x |
as in print.dmdScheme_validation |
level |
as in print.dmdScheme_validation |
listLevel |
as in print.dmdScheme_validation |
error |
numeric v ector, containing error levels to print. Default is all error levels. |
as in print.dmdScheme_validation
dmdScheme_validation
objectWhen using different values for format
, different outputs are generated:
"default"print x
as list
"summary"print the description and errors of x
as structured output, using the format as specified in the argument format
"details"print the details of x
as structured output, using the format as specified in the argument format
## S3 method for class 'dmdScheme_validation' print( x, level = 1, listLevel = 3, type = "default", format = "markdown", error = c(0, 1, 2, 3, NA), ... )
## S3 method for class 'dmdScheme_validation' print( x, level = 1, listLevel = 3, type = "default", format = "markdown", error = c(0, 1, 2, 3, NA), ... )
x |
object of class |
level |
level at which the header structure should start |
listLevel |
level at which the elements should be represented as lists and not headers anymore |
type |
type of output, can be either |
format |
format in which the details tables should be printed. All values as used in |
error |
numeric v ector, containing error levels to print. Default is all error levels. |
... |
additional arguments for the function |
invisibly returns x
x <- validate(dmdScheme_raw()) ## default printout as list x ## the same as print(x, type = "default") ## the summary print(x, type = "summary") ## and the details print(x, type = "details") ## can be used in a Rmd file like: # ```{r, results = "asis"} # print(result, level = 2, listLevel = 20, type = "summary") # ```
x <- validate(dmdScheme_raw()) ## default printout as list x ## the same as print(x, type = "default") ## the summary print(x, type = "summary") ## and the details print(x, type = "details") ## can be used in a Rmd file like: # ```{r, results = "asis"} # print(result, level = 2, listLevel = 20, type = "summary") # ```
dmdSchemeData
objectPrint method for dmdSchemeData
object
## S3 method for class 'dmdSchemeData' print( x, ..., printAttr = TRUE, printExtAttr = FALSE, printData = TRUE, .prefix = "" )
## S3 method for class 'dmdSchemeData' print( x, ..., printAttr = TRUE, printExtAttr = FALSE, printData = TRUE, .prefix = "" )
x |
object of type |
... |
additional arguments - not used here |
printAttr |
default |
printExtAttr |
default |
printData |
default |
.prefix |
mainly for internal use - prefix for all printed lines |
invisibly x
dmdSchemeSet
objectPrint method for dmdSchemeSet
object
## S3 method for class 'dmdSchemeSet' print( x, ..., printAttr = TRUE, printExtAttr = FALSE, printData = TRUE, .prefix = "" )
## S3 method for class 'dmdSchemeSet' print( x, ..., printAttr = TRUE, printExtAttr = FALSE, printData = TRUE, .prefix = "" )
x |
object of type |
... |
additional arguments - not used here |
printAttr |
default |
printExtAttr |
default |
printData |
default |
.prefix |
mainly for internal use - prefix for all printed lines |
invisibly x
dmdSchemeSet
objectReads the data from an Excel file. Validation of the scheme version and
scheme name is always done. Additional validations are done depending on the
arguments validate
. See detals below.
read_excel( file, keepData = TRUE, verbose = FALSE, raw = FALSE, validate = TRUE )
read_excel( file, keepData = TRUE, verbose = FALSE, raw = FALSE, validate = TRUE )
file |
the name of the Excel file (.xls or .xlsx) containing the data to be read. |
keepData |
if |
verbose |
give verbose progress info. Useful for debugging. |
raw |
if |
validate |
if |
either if raw = TRUE
a list of data.frames from the worksheets of
Class dmdScheme_raw
, otherwise an object of class
dmdSchemeSet
fn <- scheme_path_xlsx() read_excel( file = fn ) read_excel( file = fn, raw = TRUE )
fn <- scheme_path_xlsx() read_excel( file = fn ) read_excel( file = fn, raw = TRUE )
dmdScheme_raw
objectReads the data from an Excel file as is and no validation. Only validation of
the scheme version and scheme name is done (when checkVersion = TRUE
).
read_excel_raw(file, verbose = FALSE, checkVersion = TRUE)
read_excel_raw(file, verbose = FALSE, checkVersion = TRUE)
file |
the name of the Excel file (.xls or .xlsx) containing the data to be read. |
verbose |
give verbose progress info. Useful for debugging. |
checkVersion |
if |
object of class dmdScheme_raw
read_excel_raw( scheme_path_xlsx() )
read_excel_raw( scheme_path_xlsx() )
Read the XML file file
and convert it to a dmdScheme
object using the function as_dmdScheme()
.
read_xml(file, keepData = TRUE, useSchemeInXml = NULL, verbose = FALSE)
read_xml(file, keepData = TRUE, useSchemeInXml = NULL, verbose = FALSE)
file |
Path to file or connection to write to. |
keepData |
if the data should be kept or replaced with one row with NAs |
useSchemeInXml |
if |
verbose |
give verbose progress info. Useful for debugging. |
# write_xml(dmdScheme_raw(), file = tempfile())
# write_xml(dmdScheme_raw(), file = tempfile())
x
This generic function creates a report based on the object.
report( x, file = tempfile(), open = TRUE, report = "html", report_author = "Myself", report_title = "Report of something", ... ) ## S3 method for class 'character' report( x, file = tempfile(), open = TRUE, report = "html", report_author = "Tester", report_title = "Validation of data against dmdScheme", ... ) ## S3 method for class 'dmdScheme_validation' report( x, file = tempfile(), open = TRUE, report = "html", report_author = "Tester", report_title = "Validation of data against dmdScheme", ... )
report( x, file = tempfile(), open = TRUE, report = "html", report_author = "Myself", report_title = "Report of something", ... ) ## S3 method for class 'character' report( x, file = tempfile(), open = TRUE, report = "html", report_author = "Tester", report_title = "Validation of data against dmdScheme", ... ) ## S3 method for class 'dmdScheme_validation' report( x, file = tempfile(), open = TRUE, report = "html", report_author = "Tester", report_title = "Validation of data against dmdScheme", ... )
x |
object of which the report should be creted used to select a method |
file |
name of the file containing the generated report, including extension. If missing, ot will be saved as a temporary file in the temporary folder. |
open |
if |
report |
determines if and in which format a report of the validation should be generated. Allowed values are:
|
report_author |
name of the author to be included in the report |
report_title |
title of the report to be included in the report |
... |
further arguments passed to or from other methods |
report.character
creates a report of the object returnes from a validate()
.
report.dmdScheme_validation
creates a report of the object returnes from a validate()
.
return the path and filename of the report
report(character)
: report of a dmdScheme_validation
object.
report(dmdScheme_validation)
: report of a dmdScheme_validation
object.
## Not run: ## This examples requires pandoc ## Report of `dmdScheme_validation` report( scheme_path_xlsx() ) ## End(Not run) ## Report of `dmdScheme_validation` ## Not run: # This needs pandoc to run successfully report( validate(dmdScheme_raw()) ) report( x = dmdScheme_raw(), report = "html", report_author = "The Author I am", report_title = "A Nice Report" ) ## End(Not run)
## Not run: ## This examples requires pandoc ## Report of `dmdScheme_validation` report( scheme_path_xlsx() ) ## End(Not run) ## Report of `dmdScheme_validation` ## Not run: # This needs pandoc to run successfully report( validate(dmdScheme_raw()) ) report( x = dmdScheme_raw(), report = "html", report_author = "The Author I am", report_title = "A Nice Report" ) ## End(Not run)
The shiny app allows the entering, validating, and exporting of the metadata without using R. See https://deanattali.com/2015/04/21/r-package-shiny-app/
run_app()
run_app()
return value from runApp()
## Not run: run_app() ## End(Not run)
## Not run: run_app() ## End(Not run)
scheme_active()
: Shows the name and version of the active scheme.
scheme_default()
: Shows the name of the default scheme which
comes with the package and can not be deleted. If name
and
version
is specified, the default scheme to be used will be set.
There is no need to do this only internally!. Otherwise, the scheme
repository used is only returned.
scheme_download()
: Scheme definitions can be stored in an online repo. The default is a github
repo at https://github.com/Exp-Micro-Ecol-Hub/dmdSchemeRepository. This
function dowloads a scheme definition, specified by name
and
version
, and saves it locally under the name destfile
scheme_install()
: Installed schemes are copied to
cache("installedSchemes")
and , if necessary, an .xlsx
definition is saved in addition. These can be listed by using
scheme_list.
scheme_install_r_package()
: Install R package for scheme
name
version
definition using the script
install_R_package.R
in the scheme package.
scheme_installed()
: Checks if a scheme is installed
scheme_list()
: Lists all definitions for schemes which are installed. Each follows the
pattern SCHEMENAME_SCHEMEVERSION.EXT
. All files with the same basename
but different extensions represent different representations of the same
scheme definition and are effectively equivalent, only that the tab
Documentation can only be found in the .xls
files.
scheme_list_in_repo()
: Scheme definitions can be stored in an online repo.
scheme_repo()
: Get or set scheme repository. If repo
is specified, the scheme
repository to be used is set. Otherwise, the scheme repository used is only
returned.
scheme_uninstall()
: Installed schemes are deleted from
cache("installedSchemes")
and moved to a temporary folder which is
rteturned invisibly.
scheme_use()
: Switch from the current scheme to a new scheme as defined in the scheme
schemeDefinition
. Installed schemes can be listed by using scheme_list()
.
New schemes can be added to the library via a call to scheme_add()
.
The name of the active scheme is saved in dmdScheme_active
scheme_active() scheme_default(name = NULL, version = NULL) scheme_download( name, version, destfile = NULL, overwrite = FALSE, baseurl = scheme_repo(), ... ) scheme_install( name, version, repo = scheme_repo(), file = NULL, overwrite = FALSE, install_package = FALSE ) scheme_install_r_package(name, version, reinstall = FALSE) scheme_installed(name, version) scheme_list() scheme_list_in_repo(baseurl = scheme_repo(), ...) scheme_repo(repo = NULL) scheme_uninstall(name = NULL, version = NULL) scheme_use(name = NULL, version = NULL)
scheme_active() scheme_default(name = NULL, version = NULL) scheme_download( name, version, destfile = NULL, overwrite = FALSE, baseurl = scheme_repo(), ... ) scheme_install( name, version, repo = scheme_repo(), file = NULL, overwrite = FALSE, install_package = FALSE ) scheme_install_r_package(name, version, reinstall = FALSE) scheme_installed(name, version) scheme_list() scheme_list_in_repo(baseurl = scheme_repo(), ...) scheme_repo(repo = NULL) scheme_uninstall(name = NULL, version = NULL) scheme_use(name = NULL, version = NULL)
name |
a |
version |
a |
destfile |
a |
overwrite |
if |
baseurl |
a |
... |
additional parameter for the function |
repo |
repo of the schemes. |
file |
if give, this file will be used as the local scheme definition,
and |
install_package |
if |
reinstall |
if |
data.frame
with two columns containing name and version of the default scheme
data.frame
with two columns containing name and version of the default scheme
invisibly the value of destfile
invisibly NULL
invisibly NULL
TRUE
if the theme is installed, FALSE
if not
data.frame
with two columns containing name and version of the intalled schemes
Returns the info about the scheme definitions in this repo as a list
.
URL of the repo toi be used. If not set previously, the default repo at https://github.com/Exp-Micro-Ecol-Hub/dmdSchemeRepository/ is used.
invisibly returns the temporary location where the scheme definition is moved to.
scheme_active() scheme_default() scheme_download( name = "dmdScheme", version = "0.9.5" ) ## Not run: scheme_install("path/to/definition.xml") scheme_install("path/to/definition.xlsx") ## End(Not run) ## Not run: scheme_install_r_package() ## End(Not run) ## Not run: scheme_installed("dmdScheme", "0.9.9") scheme_installed("dmdScheme", "0.7.3") ## End(Not run) scheme_list_in_repo() # returns the repo used: scheme_repo() ## Not run: scheme_uninstall(name = "schemename", version = "schemeversion") ## End(Not run) scheme_list() scheme_use(name = "dmdScheme", version = "0.9.9")
scheme_active() scheme_default() scheme_download( name = "dmdScheme", version = "0.9.5" ) ## Not run: scheme_install("path/to/definition.xml") scheme_install("path/to/definition.xlsx") ## End(Not run) ## Not run: scheme_install_r_package() ## End(Not run) ## Not run: scheme_installed("dmdScheme", "0.9.9") scheme_installed("dmdScheme", "0.7.3") ## End(Not run) scheme_list_in_repo() # returns the repo used: scheme_repo() ## Not run: scheme_uninstall(name = "schemename", version = "schemeversion") ## End(Not run) scheme_list() scheme_use(name = "dmdScheme", version = "0.9.9")
Functions to manage schemes
scheme_make( schemeDefinition, examples = NULL, install_R_package = NULL, path = ".", overwrite = FALSE, index_template = NULL )
scheme_make( schemeDefinition, examples = NULL, install_R_package = NULL, path = ".", overwrite = FALSE, index_template = NULL )
schemeDefinition |
path to the |
examples |
character vector of directories which should be included as
examples. The name of the director will be the name of the example. The
example can contain a file with the name |
install_R_package |
path to the R script to install the R package. If |
path |
where the final scheme definition should be created. |
overwrite |
if |
index_template |
the index template file which can be added |
fully qualified path to the created scheme
Functions to manage schemes
scheme_path_index_template()
scheme_path_index_template()
fully qualified path to the index
template file
scheme_path_index_template()
scheme_path_index_template()
Functions to manage schemes
scheme_path_xlsx()
scheme_path_xlsx()
fully qualified path to the xlsx
file containing the scheme definitipn and the example, NULL
if it does not exist.
scheme_path_xlsx()
scheme_path_xlsx()
Functions to manage schemes
scheme_path_xml()
scheme_path_xml()
fully qualified path to the xml
file containing the scheme definitipn and the example, NULL
if it does not exist.
scheme_path_xlsx()
scheme_path_xlsx()
Tabs in the Excel document need to be, for processing, transposed, if they are vertical as the Experiment tab is.
toTranspose(tabs = NULL)
toTranspose(tabs = NULL)
tabs |
if |
if tabs
is null, the character
vector containing the
sheets which need to be transposed. If tabs
is not NULL, a
logical
vector of the same length as tabs
which is
TRUE
, if the tab needs to be transposed, otherwise FALSE
.
toTranspose() # [1] "Experiment" "MdBibliometric" toTranspose(c("Experiment", "Not")) # [1] TRUE FALSE
toTranspose() # [1] "Experiment" "MdBibliometric" toTranspose(c("Experiment", "Not")) # [1] TRUE FALSE
Only the newest versions of xlsx
and xml
files can be processed
by this package. To gurantee, this function provides a mechanism to convert
older versions of xlsx
and xml
files to newer versions.
upgrade_old_files(file, to = scheme_active()$version)
upgrade_old_files(file, to = scheme_active()$version)
file |
file name of |
to |
version to upgrade to. Any version supported is possible, downgrade is not supported. |
if a conversion has been done, file name of upgraded spreadsheet
(BASENAME(x).to.EXTENSION(x)
where x
is the original file
name and to
is the new version), otherwise NULL
.
## Not run: upgrade("dmdScheme.xlsx") upgrade("dmdScheme.xml") ## End(Not run)
## Not run: upgrade("dmdScheme.xlsx") upgrade("dmdScheme.xml") ## End(Not run)
dmdScheme_validation
Extract all fields named error of class dmdScheme_validation
valErr_extract(x, returnRootError = FALSE)
valErr_extract(x, returnRootError = FALSE)
x |
object of class |
returnRootError |
if |
named numeric vector of the error levels of the different validations done
Return info about error representation
valErr_info(error)
valErr_info(error)
error |
either level, text or colour of error (see |
the row from valErr_errorLevels corresponding to the argument error
data.frame
from object of class dmdScheme_validation
for usage in details
of validationCreates data.frame
from object of class dmdScheme_validation
for usage in details
of validation
valErr_isOK(x, returnRootError = FALSE)
valErr_isOK(x, returnRootError = FALSE)
x |
|
returnRootError |
if |
named numeric vector of the error levels of the different validations done
text
by using the error colourColour the text
by using the error colour
valErr_TextErrCol(text, error, addError = TRUE)
valErr_TextErrCol(text, error, addError = TRUE)
text |
to be coloured. if not supplied, the coloured error text will be
returned. If |
error |
either level, text or colour of error (see |
addError |
if the error text should be added in the front of the |
the coloured text or error text
dmdScheme
This function validates an object representing a dmdScheme
. The result can
be used as a basis for a report by running report()
on the resultiung
object of class dmdScheme_validation
.
validate(x, path = ".", validateData = TRUE, errorIfStructFalse = TRUE) ## S3 method for class 'character' validate(x, path = ".", validateData = TRUE, errorIfStructFalse = TRUE) ## S3 method for class 'dmdSchemeSet_raw' validate(x, path = ".", validateData = TRUE, errorIfStructFalse = TRUE)
validate(x, path = ".", validateData = TRUE, errorIfStructFalse = TRUE) ## S3 method for class 'character' validate(x, path = ".", validateData = TRUE, errorIfStructFalse = TRUE) ## S3 method for class 'dmdSchemeSet_raw' validate(x, path = ".", validateData = TRUE, errorIfStructFalse = TRUE)
x |
object referring to a |
path |
path to the data files |
validateData |
if |
errorIfStructFalse |
if |
return the dmdScheme_validation
object
validate(character)
: validate a character
object referring to a spreadsheet file which contains the metadata.
validate(dmdSchemeSet_raw)
: validate a dmdSchemeSet_raw
object
## validata an Excel file containing the metadata validate( x = scheme_path_xlsx() ) ## validate a `dmdScheme_raw object` validate( x = dmdScheme_raw() ) ## use `read_raw()` to read an Excel spreadsheet into a `dmdScheme_raw` object x <- read_excel_raw( scheme_path_xlsx() ) validate( x = x )
## validata an Excel file containing the metadata validate( x = scheme_path_xlsx() ) ## validate a `dmdScheme_raw object` validate( x = dmdScheme_raw() ) ## use `read_raw()` to read an Excel spreadsheet into a `dmdScheme_raw` object x <- read_excel_raw( scheme_path_xlsx() ) validate( x = x )
Validate allowed values
validateAllowedValues(sraw)
validateAllowedValues(sraw)
sraw |
object of type |
dmdScheme_validation
object
Validate suggested values
validateDataFileMetaDataDataFileExists(xraw, path)
validateDataFileMetaDataDataFileExists(xraw, path)
xraw |
object of type |
path |
path to the data files |
dmdScheme_validation
object
Validate id field
validateIDField(sraw)
validateIDField(sraw)
sraw |
object of type |
dmdScheme_validation
object
dmdScheme
objectValidate structure of dmdScheme
object
validateStructure(x)
validateStructure(x)
x |
object of type |
dmdScheme_validation
object
Validate suggested values
validateSuggestedValues(sraw)
validateSuggestedValues(sraw)
sraw |
object of type |
dmdScheme_validation
object
Validate type of tab
validateTypes(sraw, sconv)
validateTypes(sraw, sconv)
sraw |
object of type |
sconv |
object of type |
dmdScheme_validation
object
Convert the object x
to an xml_document
object using the function as_xml()
and write it to a file.
If no method as_xml()
exists for the object |classx, an error will be raised.
write_excel(x, file, ...)
write_excel(x, file, ...)
x |
object which can be convertewd to a |
file |
Path to file or connection to write to. |
... |
additional parameter for the conversion function |
invisibly returns the path to the file saved to
write_excel(dmdScheme(), file = tempfile()) write_excel(dmdScheme_raw(), file = tempfile())
write_excel(dmdScheme(), file = tempfile()) write_excel(dmdScheme_raw(), file = tempfile())
Convert the object x
to an xml_document
object using the function as_xml()
and write it to a file.
If no method as_xml()
exists for the object |classx, an error will be raised.
write_xml(x, file, output = "metadata", ...)
write_xml(x, file, output = "metadata", ...)
x |
object which will be converted to and saved as an xml file. |
file |
Path to file or connection to write to. |
output |
specifies the content and format of the exported xml. see as_xml for details |
... |
additional parameter for the conversion function |
write_xml(dmdScheme(), file = tempfile())
write_xml(dmdScheme(), file = tempfile())