Template based on bookdown.
Refer to a sub section. Citing an article [@article]. Refer to section [Analysis].
Loading libraries:
library(DT)
library(ggplot2)
library(xfun)
Vestibulum
imperdiet ^[In eget eros sit amet leo feugiat consequat], ex vel sodales facilisis, nibh tellus imperdiet massa, sit amet scelerisque orci velit vel tellus. Ut consequat justo tincidunt porttitor varius. Suspendisse erat ipsum, feugiat vitae rhoncus non, molestie ac purus. Morbi aliquet, elit eget blandit suscipit, est lacus facilisis turpis, nec fermentum nunc felis et lorem.
:::{#Table1} A nice table example: :::
DT::datatable(mtcars, options = list(pageLength = 3))
Suspendisse potenti
We can have math formulas inline like this: $E=mc^2$ or make them span an entire line like this: \begin{equation} f=\frac{a}{b+c} (#eq:eq1) \end{equation}
Create a horizontal line using markdown syntax:
Cras pulvinar ligula ac nisi porttitor, volutpat congue orci tincidunt. Pellentesque non mi congue, porta enim eget, venenatis sem. Integer suscipit vulputate tellus, eget commodo dolor gravida vel. Suspendisse gravida gravida ligula, in interdum sapien molestie ut.
:::{.blue-box} In ut vehicula risus. Refer to the table above! :::
options(scipen=999) # turn-off scientific notation like 1e+48
theme_set(theme_bw()) # pre-set the bw theme.
data("midwest", package = "ggplot2")
# midwest <- read.csv("http://goo.gl/G1K41K") # bkup data source
# Scatterplot
gg = ggplot(midwest, aes(x=area, y=poptotal)) +
geom_point(aes(col=state, size=popdensity)) +
geom_smooth(method="loess", se=F) +
xlim(c(0, 0.1)) +
ylim(c(0, 500000)) +
labs(subtitle="Area Vs Population",
y="Population",
x="Area",
title="Scatterplot",
caption = "Source: midwest")
plot(gg)
## `geom_smooth()` using formula 'y ~ x'
Remember equation \@ref(eq:eq1)!
:::{#box1 .green-box} Wrapping it up! :::
:::{#caution-text .caution}
:::{#warning-text .warning} Be careful, be gentle, be brave! And remember the above box! :::
:::{#tip-text .tip} A tip! :::
:::{#note-text .note} A note! :::
:::{#important-text .important} I have something important to say here! :::
:::{.orange-box} An orange box!!! Remember figure (\@ref(fig:example-plot))! :::
```{.r .fold-show} xfun::session_info()
R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.1 LTS
Locale:
LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C
LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
Package version:
assertthat_0.2.1 backports_1.1.10 base64enc_0.1.3 BH_1.72.0.3
bookdown_0.21 callr_3.5.1 cli_2.1.0 colorspace_1.4-1
compiler_3.6.3 crayon_1.3.4 crosstalk_1.1.0.1 desc_1.2.0
digest_0.6.27 dplyr_1.0.2 DT_0.16 ellipsis_0.3.1
evaluate_0.14 fansi_0.4.1 farver_2.0.3 generics_0.0.2
ggplot2_3.3.2 glue_1.4.2 graphics_3.6.3 grDevices_3.6.3
grid_3.6.3 gtable_0.3.0 highr_0.8 htmltools_0.5.0
htmlwidgets_1.5.2 isoband_0.2.2 jsonlite_1.7.1 knitr_1.30
labeling_0.4.2 later_1.1.0.1 lattice_0.20-41 lazyeval_0.2.2
lifecycle_0.2.0 magrittr_1.5 markdown_1.1 MASS_7.3.53
Matrix_1.2-18 methods_3.6.3 mgcv_1.8-33 mime_0.9
munsell_0.5.0 nlme_3.1-149 pillar_1.4.6 pkgbuild_1.1.0
pkgconfig_2.0.3 pkgload_1.1.0 praise_1.0.0 prettyunits_1.1.1
processx_3.4.4 promises_1.1.1 ps_1.4.0 purrr_0.3.4
R6_2.4.1 RColorBrewer_1.1.2 Rcpp_1.0.5 rlang_0.4.8
rmarkdown_2.5 rprojroot_1.3.2 rstudioapi_0.11 scales_1.1.1
splines_3.6.3 stats_3.6.3 stringi_1.5.3 stringr_1.4.0
testthat_2.3.2 tibble_3.0.4 tidyselect_1.1.0 tinytex_0.26
tools_3.6.3 utf8_1.1.4 utils_3.6.3 vctrs_0.3.4
viridisLite_0.3.0 withr_2.3.0 xfun_0.18 yaml_2.2.1
```