forked from ropensci/EML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
95 lines (59 loc) · 2.26 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
[![Travis-CI Build Status](https://travis-ci.org/cboettig/EML.svg?branch=master)](https://travis-ci.org/cboettig/EML)
# EML
*Note*: `EML` is work in progress. Please see the Issues tracker in this repository for details about current issues and development milestonds.
## Installation
`EML` has not yet been released. Please install from GitHub after installing the `devtools` package (from CRAN):
```{r eval=FALSE}
devtools::install_github("cboettig/EML")
```
## Quickstart
Load the package and read in an EML file:
```{r}
library("EML")
f <- system.file("xsd/test/eml.xml", package = "EML")
eml <- read_eml(f)
```
This creates a native R object called `eml`. Although this is an "S4 object" type, it uses a "show"
method which displays in an XML-like layout for convenience:
```{r}
eml
```
Validate EML against the official schema
```{r, message=TRUE}
# An EML document with no validation errors
eml_validate(eml)
# An EML document with validation errors
invalid_eml <- system.file("tests/testthat/", "example-eml-invalid.xml", package = "EML")
eml_validate(invalid_eml)
```
Write out as EML:
```{r}
write_eml(eml, "example.xml")
```
```{r include=FALSE, echo=FALSE}
unlink("example.xml")
```
## Manipulating EML objects
Eventually `EML` will provide constructor and extract methods to create and extract common metadata sections from convenient R stuctures (e.g. `data.frames` with unit metadata, common R classes like `Person`, `bibtype`). For now, the only method to access and modify EML is to use the standard S4 subsetting and constructor methods.
Our current example does not have a publication date. Let's add one:
```{r}
eml@dataset@ResourceGroup@pubDate <- new("pubDate", "2016")
```
Note that we use the constructor method `new()` to create an object.
### Working with repeating elements
## Developer notes
### Creating EML class definitions
Class definitions (`classes.R`) and methods (`methods.R`) are created programmatically. From the root of the package, run: `source("inst/create-package/create_package.R")`.