This is an RMarkdown document. Markdown is a simple
formatting syntax for authoring HTML, PDF, and MS Word documents. For
more details on using R Markdown see https://rmarkdown.rstudio.com (archived at https://perma.cc/4MP3-5RT8)
You can embed an R code chunk like this:
```{r}
summary(cars)
```
summary(cars)
speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00
Use a new line for every sentence. This helps with
version control—individually changed sentences will be highlighted upon
commits (which are easy to parse to identify the specific changes)
rather than whole paragraphs (which are a nightmare to parse to identify
the specific changes).
This formatting is incompatible with a double space after a period.
Instead, use a single space after a period. To replace all double spaces
with single spaces, do a find and replace for ". " →
". " Be careful not to blanket remove all double spaces
because tabbed bullets have 3 spaces.
Add protocol entries as links to the parent .Rmd file
(or to README.md)
Add linked content (e.g., images) to sub-directories
Use no spaces in file or folder names. Use a dash (-) instead of a
space.
If you use Visual Studio Code to edit the Lab Wiki, you
can view the source code side-by-side with the markdown Preview (after
selecting the code type as markdown):
When making numbered (ordered) lists, just use 1. for
all numbers. Markdown will make them sequential automatically. This is
helpful if you go back and add additional entries later.
For all quotation marks, use straight quotes (',
") rather than curly quotes (‘,
’, “, ”).
Use "[XXX]" to indicate an area that needs editing.
This will allow the lab to CTRL+F for "[XXX]"
and find areas that need editing.
To update the list of R packages that are installed for
running the .Rmd files, update the DESCRIPTION
file.
To update the lab wiki, perform the following steps:
(Perform this step if you do not already have the the LabWiki GitHub
repo on your local machine:) Clone the GitHub repo to
your local machine.
Fetch the latest version of the repo. It is important to do this to
make sure you have the latest version locally before making any
changes.
Edit the relevant .Rmd files using RStudio
or Visual Studio Code.
Preview the wiki before you commit changes to the site; create the
.html files locally (in a folder called _site)
by running the following command:
rmarkdown::render_site()
If the .html files look correct, commit the
changes.
Push the changes to the GitHub repo. After pushing the
changes to the GitHub repo, GitHub Actions
will automatically re-run the code and deploy the updated website,
assuming there were no errors. You can track the workflow for errors
here: https://github.com/DevPsyLab/LabWiki/actions.
For more information about the rmarkdown package that
was used to generate the site, see the following links:
If you use Visual Studio Code to create/edit
.Rmd documents, you can view the source code side-by-side
with the markdown Preview (after selecting the code type as
markdown):
3.2 RStudio
3.2.1 Creating a Code
Chunk
Add a new chunk by clicking the Insert Chunk button on the
toolbar or by pressing Ctrl+Alt+I.
3.2.2 Running a Code
Chunk
You can execute a code chunk in an R Markdown Notebook
by clicking the Run button within the chunk or by placing your
cursor inside it and pressing Ctrl+Shift+Enter. To run more
than one code chunk, you have several options:
click the Run button within the chunks you want to run
select “Run All Chunks Above”
select “Run All Chunks Below”
select “Run All”
3.2.3 Creating the HTML
Output
When you click the Knit button, a document will be
generated that includes both content as well as the output of any
embedded Rcode chunks within the document.
When you save the computational notebook (.Rmd), an HTML
(.html) file containing the code and output will be saved
alongside it (click the Preview button or press
Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the
editor. Consequently, unlike Knit, Preview does not
run any R code chunks. Instead, the output of the chunk
when it was last run in the editor is displayed.
4 Computational
Notebook
4.1 General Info
You can use an R Markdown Notebook to create a
computational notebook. For more information on the value of
computational notebooks, see the article titled “The
Scientific Paper Is Obsolete”. For more information about how to
create R Notebooks, see here:
Consistent with the Petersen Lab
template for how to structure your repo, you should have two
computational notebooks: 1) a “Prepare Data” script
(prepareData.Rmd) and 2) a “Computational Notebook” script
(computationalNotebook.Rmd). The “Prepare Data” script is
used to update the data file by re-exporting, merging, re-running
calculations, etc. This script should be separate from the
“Computational Notebook” file that is used for running analyses on the
data. Every time you run the “Computational Notebook” file with the
exact same data, you should get the exact same findings (i.e.,
reproducibility). Thus, we keep the “Prepare Data script” separate from
the “Computational Notebook” file so that you update the data only when
you intend to.
4.3 Structure
When creating a computational notebook, follow the structure of the
computational notebooks in the Petersen Lab
template.
To use the lab templates for the “Prepare Data” and “Computational
Notebook” scripts, first install the petersenlab package. Then, in
RStudio, select “File” > “New File” > “R Markdown”.
Then, select “From Template”, and select either the “prepareData” or
“computationalNotebook” template.
If you want to create a computational notebook manually (instead of
using the lab template), create a .Rmd file with the
following YAML header at the top of the file:
If this is your “Computational Notebook” script, include the
following as the first code chunk:
```{r setup, include = FALSE}
knitr::opts_chunk$set(
echo = TRUE, # print code
error = TRUE # do not interrupt in case of errors
)
# Use for higher quality figures on Windows devices
trace(grDevices::png, quote({
if (missing(type) && missing(antialias)) {
type <- "cairo-png"
antialias <- "subpixel"
}
}), print = FALSE)
```
If this is your “Prepare Data” script, include the following as the
first code chunk:
The following specifications may be added to your command:
font-size: Value = percentage
e.g., font-size: 150%
font-style: Value = bold,
italic, underline
e.g., font-style: bold,
font-style: italic
color: Value = color name or
color code
e.g., color: green, color: #0e6b1c
To edit the command to add quotations, include the following
after the end bracket of the command:
COMMAND_NAME:before { content: open-quote; } COMMAND_NAME:after { content: close-quote; }
includes contains css files, javascript
files, footers, and Google Analytics
If the rmarkdown website is intended to be public,
create a new Google Analytics property, and replace the URL and gtag in
the google_analytics.html file
Commit the repo to GitHub
To deploy the website on GitHub Pages:
Make the repo public (Settings > General > Change
Visibility)
Activate GitHub Pages (Settings > Pages)
Source: “Deploy from a Branch”
Branch: gh-pages/root
Click “Save”
Make sure “Read and write permissions” are enabled in Settings ->
Actions -> General -> Workflow permissions
To prevent code from re-running unless code is altered:
execute:
freeze: auto
5.3 Troubleshooting
If you get the following error in GitHub Actions:
remote: Permission to GITHUB_USERNAME/REPO_NAME.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/GITHUB_USERNAME/REPO_NAME.git/': The requested URL returned error: 403
To add another element in a list while preserving the continuity of
the list, indent the element four spaces or one tab.
8.1 Unordered Lists
To create an unordered list, add a dash (-) in front of line items.
Adding an asterisk (*) or plus sign (+) in front of line items will also
create an unordered list; however, the lab convention is to use dashes
for unordered lists. We use asterisks for adding
emphasis to text.
- one item
- one item
- one item
- one more item
- one more item
- one more item
- lower level
- sub-item 1
- sub-item 2
1. the first item
1. test
1. test
1. new test
1. new test
1. the second item
1. test
1. test
1. the third item
- one unordered item
- subitem
- one unordered item
1. fourth item
1. test
1. test
1. test
the first item
test
test
new test
new test
the second item
test
test
the third item
one unordered item
subitem
one unordered item
fourth item
test
test
test
9 Blockquotes
> Dorothy followed her through many of the beautiful rooms in her castle.
>
> Continued...
Dorothy followed her through many of the beautiful rooms in her
castle.
Continued…
10 Comments
10.1 Markdown
```markdown
[This is how to write a hidden comment in Markdown.]: #
```
[This comment will be hidden.]: #
[This is how to write a hidden comment in Markdown.]: #
10.2 HTML
<!-- This text will be hidden -->
<!--
This multiline
text comment will be
hidden
-->
11 Emphasis
This text is **bolded text**.
This text is *italicized text*.
This text is ***bolded and italicized text***.
This text is <mark>highlighted text</mark>.
This text is <mark style="background-color: lightblue">highlighted text in a different color</mark>.
This text is `unicode text`.
This text is <code><i>code in italics;</i> this text is <b>code in bold</b></code>.
This text is ~~strikethrough text~~.
This text <u>will be underlined</u>; this text <ins>will also be underlined</ins>.
<font color="red">This text is red!</font>
This text is bolded text. This text is
italicized text. This text is bolded and italicized
text. This text is highlighted text. This
text is highlighted text in a
different color. This text is unicode text. This
text is code in italics; this text is code in
bold. This text is strikethrough text. This text
will be underlined; this text will also be underlined.
This text is red!
For underlining text, the lab convention is to use:
<u>text to be underlined</u>.
12 Formatting
<center>This text is centered.</center>
This text is centered.
13 Code/Syntax
Highlighting
To use syntax highlighting to display code without running the
code:
```r
summary(cars)
```
summary(cars)
or
```{r, eval = FALSE}
summary(cars)
```
summary(cars)
or
summary(cars)
which yields:
summary(cars)
14 Math Formulas
Inline:
This is the formula: \(x = y + 5\).
Solve for \(x\).
[I'm an inline-style link](https://www.google.com)
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[I'm a relative reference to a repository file](../blob/master/LICENSE)
[You can use numbers for reference-style link definitions][1]
[I am a link to another file in this project](pca.html#overview)
[I'm a link within this document](#headings)
[I'm a link that opens in a new tab](https://example.com){target="_blank"}
URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com>
Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: https://slashdot.org/
[![DevPsyLab](images/formalLogo.png)](https://developmental-psychopathology.lab.uiowa.edu/)
Some text to show that the reference links can follow later.
Link from an image:
16 Footnotes
Here is a simple footnote[^1].
A footnote can also have multiple lines[^2].
You can also use words, to fit your writing style more closely[^note].
[^1]: My reference.
[^2]: Every new line should be prefixed with 2 spaces.
This allows you to have a footnote with multiple lines.
[^note]:
Named footnotes will still render with numbers instead of the text but allow easier identification and linking.
This footnote also has been made with a different syntax using 4 spaces for new lines.
Note:: When creating dropdown menus, it is important
to have spaces between font breaks </font>. Without
these breaks, Markdown cannot detect how to
<details>
<summary>**<font size = "6">This is a dropdown menu**</summary>
<font size = "4">
Insert Text Here
</font>
</details>
This is a dropdown menu
Insert Text Here
20 Embedding a
Picture
![Insert Figure Caption here](Insert image filename and location here)
For instance:
![Visual Studio Code](images/vsCode.png)
21 Embedding a Video
First, make sure the repository is configured for large file
storage. Follow the instructions here to
do so.
A helpful example repository for embedding videos can be found here
<video width="100%" controls="" preload="none"> #video settings
<source src="images/lv2-saving-procedures.mp4" type="video/mp4"> #location and type of video
</video>
22 Embedding a pdf in a
markdown document
PDF’s can be embedded within markdown documents. Make sure the
document you wish to embed is in a local folder (if you are adding it to
a Wiki document).
Note: Height and width can be adjusted to fit the
page
<embed src="path to file" width="1000" height="600">
23 Embedding a html file
within a markdown document
The below line of code will embed a html document in a markdown file.
The best way to configure formatting for this is still in progress.
Note: The htmltools package will need
to be installed as a package dependency
htmltools::includeHTML("path to html file")
24 Converting Word
Documents to Markdown
The process of converting word documents to Markdown is aided by
having knowledge of the best practices
steps.
To convert documents, follow these steps:
Open both word doc to be converted and new markdown document
Copy and paste the text to convert
Follow the best practices to convert
the document to Markdown format
For example, in the manuals for the School Readiness Study, each new header should denote a new task
Importantly, each sentence will correspond to one line in
markdown. To convert sentences out of paragraph form:
Press Ctrl f
search .
Next, click the arrow on the left side of the search window to open
up the replace function in Visual Studio Code.
The goal of this process is to create one sentence per line.
Creating one sentence per line. By using one sentence for line, changes
can be tracked easier.
In the Replace line, type Ctrl Enter to
create a new line.
Go through each find to determine if a new line should be created.
Do not replace all. Bulleted lists may also contain a
. that should not be removed.
25 Video formatting for
Wiki
Handbrake can be used to lower
video quality, and convert files to .mp4 format, in order
for them to be incorporated into the wiki. It is important to lower the
quality (i.e., file size) of videos so that we do not exceed the 1gb
file size limit on any given repo.
25.1 Lowering File
Size
Open Handbrake and drag and drop the video that you would like to
lower the file size of.
Select the video tab and lower the
Constant Quality to 30, and the
Framerate (FPS): to 20
We have found this lowers file size, but saves video quality
Every new line should be prefixed with 2 spaces.
This allows you to have a footnote with multiple lines.↩︎
Named footnotes will still render with numbers instead
of the text but allow easier identification and linking.
This footnote also has been made with a different syntax using 4 spaces
for new lines.↩︎
10 Comments
10.1 Markdown
10.2 HTML