Skip to content

Commit

Permalink
add skeleton of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhaonet committed Jan 31, 2019
1 parent 78e832f commit 6f7b263
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 7 deletions.
100 changes: 100 additions & 0 deletions inst/rmarkdown/templates/beamer/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: Template for using R 'xaringan' package in a 'rosr' project
output: beamer_presentation
always_allow_html: yes
---

```{r md-hint, include=FALSE}
# Markdown Syntax
# - *italic*, **bold**, `code`, ~subscript~, ^superscript^, > quote, ^[footnote]
# - $inline equation$, $$display equation$$
# - \begin{equation} (\#eq:eq-label)\end(equation), \@ref(eq:eq-label)
# - [@bib-entry1; @bib-entry2]
# - [](hyperlink)
# - ![](image link), knitr::include_graphics(), \@ref(fig:fig1)
# - knitr::kable(), \@ref(tab:tab1)
```


```{r, include=FALSE}
options(htmltools.dir.version = FALSE)
```

# Introduction

This template comes from the R 'xaringan' package and modified by Peng Zhao. It intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the original template.

---

# Methods

## Set up

Firstly, we switch off the codes and message display in a manuscript, and set the working directory to the rosr project.

```{r setup}
oldwd <- getwd()
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
knitr::opts_knit$set(root.dir = dirname(dirname(oldwd)))
```

---

## Load data

Now we can use the relative path. Let's sync the bib file and run an R script.

```{r load, results='hide'}
source('R/rosr.R')
```

---

## Numbers

As we just ran the `source()` command, we can use the results from the `R/rosr.R`. For example, the mean temperature is `r temperature` degree.

---

## Tables

We could insert a table.


```{r}
aq$Month <- as.factor(aq$Month)
DT::datatable(
aq,
fillContainer = FALSE, options = list(pageLength = 4)
)
```

---

## Figures

Plot the data in a diagram.

```{r fig-lab, fig.cap='Air quality data.'}
plot(aq)
```

---

We could insert an image.

```{r img-lab, fig.cap='Insert an image.'}
knitr::include_graphics(paste0(getwd(), '/image/rosr_R.png'))
```

---

## Equations

Use the `rosr::eq()` function to insert an equation. See Eq. \@ref(eq:sd)

```{r, results='asis'}
eqs <- 'equation/rosr-eq.Rmd'
rosr::eq(eqs, label = 'sd')
```
4 changes: 4 additions & 0 deletions inst/rmarkdown/templates/beamer/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: beamer Presentation
description: >
Create a beamer
create_dir: false
100 changes: 100 additions & 0 deletions inst/rmarkdown/templates/powerpoint/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: Template for using R 'xaringan' package in a 'rosr' project
output: powerpoint_presentation
always_allow_html: yes
---

```{r md-hint, include=FALSE}
# Markdown Syntax
# - *italic*, **bold**, `code`, ~subscript~, ^superscript^, > quote, ^[footnote]
# - $inline equation$, $$display equation$$
# - \begin{equation} (\#eq:eq-label)\end(equation), \@ref(eq:eq-label)
# - [@bib-entry1; @bib-entry2]
# - [](hyperlink)
# - ![](image link), knitr::include_graphics(), \@ref(fig:fig1)
# - knitr::kable(), \@ref(tab:tab1)
```


```{r, include=FALSE}
options(htmltools.dir.version = FALSE)
```

# Introduction

This template comes from the R 'xaringan' package and modified by Peng Zhao. It intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the original template.

---

# Methods

## Set up

Firstly, we switch off the codes and message display in a manuscript, and set the working directory to the rosr project.

```{r setup}
oldwd <- getwd()
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
knitr::opts_knit$set(root.dir = dirname(dirname(oldwd)))
```

---

## Load data

Now we can use the relative path. Let's sync the bib file and run an R script.

```{r load, results='hide'}
source('R/rosr.R')
```

---

## Numbers

As we just ran the `source()` command, we can use the results from the `R/rosr.R`. For example, the mean temperature is `r temperature` degree.

---

## Tables

We could insert a table.


```{r}
aq$Month <- as.factor(aq$Month)
DT::datatable(
aq,
fillContainer = FALSE, options = list(pageLength = 4)
)
```

---

## Figures

Plot the data in a diagram.

```{r fig-lab, fig.cap='Air quality data.'}
plot(aq)
```

---

We could insert an image.

```{r img-lab, fig.cap='Insert an image.'}
knitr::include_graphics(paste0(getwd(), '/image/rosr_R.png'))
```

---

## Equations

Use the `rosr::eq()` function to insert an equation. See Eq. \@ref(eq:sd)

```{r, results='asis'}
eqs <- 'equation/rosr-eq.Rmd'
rosr::eq(eqs, label = 'sd')
```
4 changes: 4 additions & 0 deletions inst/rmarkdown/templates/powerpoint/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: Powerpoint Presentation
description: >
Create a powerpoint presentation
create_dir: false
4 changes: 4 additions & 0 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Name: Create a rosr project
Description: Create a interconnected R Markdown project for reproducible research
Binding: create_ui
Interactive: true
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ This template comes from the R 'bookdownplus' package and modified by Peng Zhao.

Firstly, we switch off the codes and message display in a manuscript, and set the working directory to the rosr project.

```{r setup}
```{r set}
oldwd <- getwd()
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
knitr::opts_knit$set(root.dir = dirname(oldwd))
knitr::opts_knit$set(root.dir = dirname(dirname(oldwd)))
```

## Load data
Expand Down Expand Up @@ -49,7 +49,7 @@ knitr::kable(head(aq), booktabs = TRUE, caption = 'Air quality data.')

Plot the data in a diagram as shown in Fig. \@ref(fig:fig-lab).

```{r fig-lab, fig.cap='Air quality data.', out.width='100%'}
```{r fig-lab, fig.cap='Air quality data.'}
plot(aq)
```

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ output:

## Introduction

This template comes from the R 'drposter' package and modified by Peng Zhao. It intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the 'drposter' template.
This template comes from the R 'drposter' package and modified by Peng Zhao. It intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the original template.

## Set up

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ options(htmltools.dir.version = FALSE)

# Introduction

This template comes from the R 'xaringan' package and modified by Peng Zhao. It intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the 'xaringan' template.
This template comes from the R 'xaringan' package and modified by Peng Zhao. It intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the original template.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Firstly, we set the codes and message display, and set the working directory to
```{r setup}
oldwd <- getwd()
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
knitr::opts_knit$set(root.dir = dirname(dirname(dirname(oldwd))))
knitr::opts_knit$set(root.dir = dirname(dirname(dirname(dirname(oldwd)))))
```

## Load data
Expand Down Expand Up @@ -80,7 +80,7 @@ plot(aq)
We could insert an image like Fig \@ref(fig:img-lab).

```{r}
file.copy(dir('image/', full.names = TRUE), 'website/static/image/', recursive = TRUE, overwrite = TRUE)
file.copy(dir('image/', full.names = TRUE), file.path(dirname(dirname(oldwd)), 'static', 'image'), recursive = TRUE, overwrite = TRUE)
```

```{r img-lab, fig.cap='Insert an image.'}
Expand Down

0 comments on commit 6f7b263

Please sign in to comment.