Use rosr in blogdown"

# 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)

Introduction

This template intends to show how to cross refer other files in a 'rosr' project, rather than to show how to use the 'blogdown' package.

Methods

Set up

Firstly, we set the codes and message display, and set the working directory to the rosr project.

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

Load data

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

source('R/rosr.R')

Cite

Here we cite something like this:

file.copy('bib/rosr.bib', paste0(oldwd, '/bib/rosr.bib'))

Many R packages have been developed recently [@R-pinyin; @R-beginr; @R-bookdownplus; @R-mindr; @R-rmd; @R-steemr].

Results and Discussions

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 as in Table \@ref(tab:tab-lab).

print(getwd())
knitr::kable(head(aq), booktabs = TRUE, caption = 'Air quality data.')

Figures

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

plot(aq)

We could insert an image like Fig \@ref(fig:img-lab).

file.copy(dir('image/', full.names = TRUE), file.path(dirname(dirname(oldwd)), 'static', 'image'), recursive = TRUE, overwrite = TRUE)
knitr::include_graphics('/image/rosr_R.png')

Equations

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

eqs <- 'equation/rosr-eq.Rmd'
rosr::eq(eqs, label = 'sd')

Conclusions

The conclusion goes here.

References



Try the rosr package in your browser

Any scripts or data that you put into this service are public.

rosr documentation built on July 2, 2020, 2:28 a.m.