-
Notifications
You must be signed in to change notification settings - Fork 1
/
rmarkdown.Rmd.jats.xml
145 lines (144 loc) · 7.12 KB
/
rmarkdown.Rmd.jats.xml
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.1d3 20150301//EN" "JATS-archivearticle1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<front>
<article-meta>
<title-group>
<article-title>RMarkdown and Stencila</article-title>
</title-group>
<contrib-group content-type="author">
<contrib contrib-type="person">
<name>
<surname>Bentley</surname>
<given-names>Nokome</given-names>
</name>
<xref ref-type="aff" rid="stencila" />
</contrib>
<contrib contrib-type="person">
<name>
<surname>Pawlik</surname>
<given-names>Aleksandra</given-names>
</name>
</contrib>
<contrib contrib-type="person">
<name>
<surname>Aufrieter</surname>
<given-names>Michael</given-names>
</name>
<xref ref-type="aff" rid="substance" />
</contrib>
<contrib contrib-type="person">
<name>
<surname>Buchtala</surname>
<given-names>Oliver</given-names>
</name>
<xref ref-type="aff" rid="substance" />
</contrib>
</contrib-group>
<aff id="stencila">
<institution content-type="orgname">Stencila</institution>
<city>Kaikoura</city>
<country>New Zealand</country>
</aff>
<aff id="substance">
<institution content-type="orgname">Substance GmbH</institution>
<city>Linz</city>
<country>Austria</country>
</aff>
<abstract>
<p>Stencila currently supports import of RMarkdown documents. This allows use cases like allowing collaborators to work on the same document using a WYSIWYG editing environment, or for you to put the final touches on a paper before final submission to a journal.</p>
</abstract>
</article-meta>
</front>
<body>
<sec id="introduction-1">
<title>Introduction</title>
<p><ext-link ext-link-type="uri" xlink:href="https://rmarkdown.rstudio.com/">RMarkdown</ext-link> is a popular format for reproducible research using the R programming language (<xref ref-type="bibr" rid="ref-1">1</xref>,<xref ref-type="bibr" rid="ref-2">2</xref>). Stencila is a able to import RMarkdown documents. For example, the source for this example document is available on <ext-link ext-link-type="uri" xlink:href="https://github.com/stencila/stencila/blob/more-examples/data/r-markdown/rmarkdown.Rmd">Github</ext-link>. Eventually, we’ll also support exporting to RMarkdown, allowing WYSIWYG editing of RMarkdown documents in Stencila.</p>
</sec>
<sec id="code-chunks-1">
<title>Code chunks</title>
<p>In RMarkdown, code “chunks” are written using “fenced” code blocks. Stencila converts these code “chunks” into Stencila code “cells” like this one:</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="r" executable="yes">n <- 500</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>Stencila cells behave like functions having zero or more named <monospace>inputs</monospace> (like function arguments) and an optional <monospace>output</monospace> (like a assigning a function’s return value). A cell’s inputs and outputs are determined by analyzing the cell’s code. The cell above has no inputs but produces an output variable named <monospace>n</monospace>. Stencila’s execution engine uses this information to make code cells reactive. For instance, the cell below has <monospace>n</monospace> as an input i.e it is dependent on the first cell. So when you update the <monospace>n</monospace> in the cell above, the following plot will update.</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="r" executable="yes">s <- min(1000, n)
x <- runif(s)
y <- x + runif(s)
z <- y + rnorm(s)
plot(x, y, cex=z*2, col=rainbow(length(z), alpha=0.5)[rank(x+z)], pch=16)</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
</sec>
<sec id="figures-1">
<title>Figures</title>
<p>In RMarkdown, code chunks can have various options. A common use for options is to set the caption and dimensions of figures. Stencila converts code chunks with the <monospace>fig.cap</monospace> option into JATS <monospace><fig fig-type="repro-fig"></monospace> elements with a <monospace><caption></monospace>. This allows the user to edit the figure caption and for automatic figure numbering and referencing (although that is not working 100% right now). Other options are placed in a comment at the top of the cell so that they are preserved (and eventually will be used to apply those options within the R execution context).</p>
<fig fig-type="repro-fig">
<caption>
<title>Figure title</title>
</caption>
<alternatives>
<code specific-use="source" language="r" executable="yes">#: fig.width=7,fig.height=6
s <- min(1000, n)
x <- runif(s)
y <- x + runif(s)
z <- y + rnorm(s)
hist(z, breaks=40, col=hsv(0.6, 0.9, 1), xlab="Value", main="")</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</fig>
</sec>
</body>
<back>
<ref-list>
<ref id="ref-1">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Baumer</surname>
<given-names>Ben</given-names>
</name>
<name>
<surname>Cetinkaya-Rundel</surname>
<given-names>Mine</given-names>
</name>
<name>
<surname>Bray</surname>
<given-names>Andrew</given-names>
</name>
<name>
<surname>Loi</surname>
<given-names>Linda</given-names>
</name>
<name>
<surname>Horton</surname>
<given-names>Nicholas J</given-names>
</name>
</person-group>
<article-title>R markdown: Integrating a reproducible analysis tool into introductory statistics</article-title>
<source>arXiv preprint arXiv:1402.1894</source>
<year>2014</year>
</element-citation>
</ref>
<ref id="ref-2">
<element-citation publication-type="book">
<person-group person-group-type="author">
<name>
<surname>Xie</surname>
<given-names>Yihui</given-names>
</name>
</person-group>
<source>Bookdown: Authoring books and technical documents with r markdown</source>
<publisher-name>CRC Press</publisher-name>
<year>2016</year>
</element-citation>
</ref>
</ref-list>
</back>
</article>