diff --git a/Lesson5_rmd.Rmd b/Lesson5_rmd.Rmd index 3c4adc2..f289453 100644 --- a/Lesson5_rmd.Rmd +++ b/Lesson5_rmd.Rmd @@ -5,6 +5,13 @@ author: | | | Your affiliation here output: + html_document: # html options + highlight: tango + code_folding: show + toc: yes + toc_depth: 4 + number_sections: no + toc_float: yes pdf_document: # pdf options highlight: tango template: null @@ -16,13 +23,6 @@ output: fig_caption: true df_print: tibble latex_engine: xelatex #pdflatex # lualatex - html_document: # html options - highlight: tango - code_folding: show - toc: yes - toc_depth: 4 - number_sections: no - toc_float: yes word_document: # ms word options highlight: tango keep_md: yes @@ -48,7 +48,7 @@ classoption: portrait MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } }); -```{r, set-options, echo = F, cache = T} +```{r, set-options, echo = F, cache = T,message=F} options(width=100) knitr::opts_chunk$set( eval = TRUE, # run all code @@ -62,7 +62,7 @@ knitr::opts_chunk$set( ### run this once # tinytex::install_tinytex() -packages <- c("DT","htmlwidgets") +packages <- c("dplyr","ggplot2","plotly","DT","htmlwidgets") ppp <- lapply(packages,require,character.only=T) names(ppp) <- packages @@ -132,7 +132,7 @@ $$ ## Embed images/gifs: -![Great power is pretty boring](img/opm.jpg). +![Great power is pretty boring](https://github.com/darwinanddavis/EmoRyCodingClub/raw/master/docs/img/opm.jpg). \newpage @@ -198,9 +198,8 @@ Table 1. Definitions of model parameters for individual hosts and **parasites**. ### Chapter 2 (with new code) Here's an Easter egg for you ... -```{r,echo=F} -require(ggplot2) -require(plotly) +```{r,echo=F,message=F} +lapply(list(require(plotly),require(ggplot2)),suppressWarnings) nn <- 100 p <- ggplot() + geom_point(aes(rnorm(nn),sample(nn/2,nn,replace=T)),colour = rainbow(nn),size=sample(nn/2,nn,replace=T)/5,alpha=abs(rnorm(nn))) + @@ -214,8 +213,7 @@ ggplotly(p) Here's a new way of creating tables using the `DT` package ```{r,cache=T,warning=F, echo=F} -require(DT) -require(htmlwidgets) +lapply(list(require(DT),require(htmlwidgets)),suppressWarnings) caption <- "Table 1. The 'mtcars' dataset presented in a datatable. Try editing the columns and cells." datatable(mtcars, rownames = T, diff --git a/Lesson5_rmd.html b/Lesson5_rmd.html deleted file mode 100644 index 95ed31f..0000000 --- a/Lesson5_rmd.html +++ /dev/null @@ -1,792 +0,0 @@ - - - - - - - - - - - - - - -Using RMarkdown for reproducible and neat documents - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
-
-
-
- -
- - - - - - - - - - - - -

Date: 2019-10-22
-R version: 3.5.0
-*Corresponding author: your email here

- -
-

Overview

-

This document showcases how to create and use RMarkdown documents.

-

You can write in bold and italicised text (in two different ways).

-

You can write in-line code if you want to differentiate between when you are typing normally or highlighting model parameters, for example.

-

Equations like this \(t' = \gamma(t - vx/c^{2})\), to appear within text lines.

-

Create links to your website.

-

Make footnotes1.

-
-
-

You can easily create headings. This is the same font size as the ‘Overview’ above

-
-

Then move down in font size

-
-

Like this subheading

-
-

And this fourth order heading

-

Insert line breaks
between text like this

-

Insert a horizontal line break using five asterisks (‘*****’)

-
-

(There is also a page break here. Best seen in PDF. Check the raw Rmd file to see the code)

-

The raw Rmd file also has the code for inserting user comments,

- -
-
-
-
-

Define equations

-

Accordingly, we write the eigenfunction of a spinless particle as the superposition of plane wave states of momentum (\(\pi\)) and energy (\(Ej\)) having amplitudes \(a(\pi,Ej)\) (from2)

-

\[ -\phi n(r,t) = - \sum_{i, j} a(p_{i},E_{j}) - e^{ - \frac{i} - {h} - (p_{i} \cdot r - E_{j}t) -} -\]  

-
-
-

Embed images/gifs:

-

Great power is pretty boring.

- -
-
-

Create, alter, and embed plots

-

-

Figure 1. Example of a stock plot embedded into a PDF from RMarkdown.

- -
-
-

Show plots with associated code

-
require(viridis)
-bm <- 0
-par(las=1,bty="n"); xlim <- c(-5,5);ylim <- c(0,0.5)
-set.seed(12)
-N <- 2000
-rr <- rnorm(N); rr2 <- rnorm(N^2); rr3 <- rnorm(N+0.3)
-rrd <- density(rr);rrd2 <- density(rr2);rrd3 <- density(rr3)
-main <- paste0(N," points but plot better");xlab <- "Points in space"
-if(bm==1){
-  layout(matrix(c(rep(1,3),2:4), 2, 3, byrow = TRUE));sc <- 1
-  plot(rr,las=1,bty="n",col=adjustcolor(viridis(N),0.5),pch=20,cex=runif(10,1,5),
-       main=main,xlab=xlab)
-for(r in list(rrd,rrd2,rrd3)){
-  plot(r,xlim=xlim,ylim=ylim,main="")
-  polygon(r,col=adjustcolor(viridis(250)[sc],0.5),border=viridis(250)[sc]);sc <- sc+100}
-}else{par(mfrow=c(1,1))
-  plot(rr,las=1,bty="n",col=adjustcolor(viridis(N),0.5),pch=20,cex=runif(10,1,5),
-       main=main,xlab=xlab)}
-

-

Figure 2. Example of a plot with improved graphics and its associated code embedded into a PDF from RMarkdown.

- -
-
-

And tables

-

Table 1. Definitions of model parameters for individual hosts and parasites. Dimensions and units: -, dimensionless; cm, centimetres; J, Joules; L, length.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDefinitionDimension
(unit)
Lstructural lengthcm
eescaled reserve densityJ (cm3)
Dhost development
RHenergy in reproduction bufferJ
- -
-
-

Use buttons or tabs for sub-chapters

-
-

Chapter 1

-

Then you can add whatever you want here like you would normally write in the Rmd file.

-
-
-

Chapter 2 (with new code)

-

Here’s an Easter egg for you …

-
- -
-
-

More tables

-

Here’s a new way of creating tables using the DT package

-
- -
-
-
-
-

Embed code from different languages

-
-

This is R code

-
if(pck==1){
-  p<-c("rJava", "RNetLogo"); remove.packages(p)
-  # then install rJava and RNetLogo from source
-  install.packages("rJava", repos = "https://cran.r-project.org/")
-  install.packages("RNetLogo", repos = "https://cran.r-project.org/")
-}
-
-
-

shell/bash

-
echo "Hello Bash!"  
-pwd # check working dir
-git init # initialise git
-
-
-

Octave (and MATLAB from the RMatlab package).

-

RMatlab documentation.

-
b = [4; 9; 2] # Column vector
-A = [ 3 4 5;
-      1 3 1;
-      3 5 9 ]
-x = A \ b     # Solve the system Ax = b
-
-
-

HTML

-
<!-- links-->
-        <div class="footer">
-            <a href="dd_feed.html" 
-            class="transition fade_in">
-                Latest post
-            </a>
-            &nbsp; &nbsp; &nbsp;
-            <a href="dd_contact.html" 
-            class="transition fade_in">
-                Contact
-            </a>
-            &nbsp; &nbsp; &nbsp;
-            <a href="dd_subscribe.html"
-            class="transition fade_in">
-                Subscribe
-            </a>
-        </div>
-
-
-

CSS

-
# custom code for the tabs in this file
-.btn {
-    border-width: 0 0px 0px 0px;
-    font-weight: normal;
-    text-transform: ;
-}
-.btn-default {
-    color: #f08080;
-    background-color: #ffffff;
-    border-color: #ffffff;
-}
-
-
-

Javascript to access html and css

-
$('.title').css('color', 'red')
-
-
-

Python

-
x = 'hello, python world!'
-print(x.split(' '))
-
-
-

Here’s a complete list of available languages

-
names(knitr::knit_engines$get())
-
##  [1] "awk"       "bash"      "coffee"    "gawk"      "groovy"   
-##  [6] "haskell"   "lein"      "mysql"     "node"      "octave"   
-## [11] "perl"      "psql"      "Rscript"   "ruby"      "sas"      
-## [16] "scala"     "sed"       "sh"        "stata"     "zsh"      
-## [21] "highlight" "Rcpp"      "tikz"      "dot"       "c"        
-## [26] "fortran"   "fortran95" "asy"       "cat"       "asis"     
-## [31] "stan"      "block"     "block2"    "js"        "css"      
-## [36] "sql"       "go"        "python"    "julia"     "sass"     
-## [41] "scss"
-
-
-
-
-
-
    -
  1. Here is the footnote you created earlier, automatically formatted

  2. -
  3. Efthimiades, S., Physical meaning and derivation of Schrodinger and Dirac equations, Department of Natural Sciences, Fordham University. doi: d34464566.

  4. -
-
- - - -
-
- -
- - - - - - - - - - - - - - - - - diff --git a/Lesson5_rmd_cache/html/__packages b/Lesson5_rmd_cache/html/__packages index b864572..21e8f79 100644 --- a/Lesson5_rmd_cache/html/__packages +++ b/Lesson5_rmd_cache/html/__packages @@ -6,3 +6,4 @@ plotly DT htmlwidgets nycflights13 +dplyr diff --git a/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.RData b/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.RData deleted file mode 100644 index 3a78686..0000000 Binary files a/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.RData and /dev/null differ diff --git a/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.rdb b/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.rdb deleted file mode 100644 index 741b2ac..0000000 Binary files a/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.rdb and /dev/null differ diff --git a/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.rdx b/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.rdx deleted file mode 100644 index 62ac0f5..0000000 Binary files a/Lesson5_rmd_cache/html/set-options_0806929b457e8a18f9deb2d274e4be10.rdx and /dev/null differ diff --git a/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.RData b/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.RData new file mode 100644 index 0000000..3b76fa9 Binary files /dev/null and b/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.RData differ diff --git a/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.rdb b/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.rdb new file mode 100644 index 0000000..e2a0067 Binary files /dev/null and b/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.rdb differ diff --git a/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.rdx b/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.rdx new file mode 100644 index 0000000..6f24b00 Binary files /dev/null and b/Lesson5_rmd_cache/html/set-options_ee647e2a2261db154eb0261661658a95.rdx differ diff --git a/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.RData b/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.RData new file mode 100644 index 0000000..c5d20b9 Binary files /dev/null and b/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.RData differ diff --git a/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.rdb b/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.rdb similarity index 100% rename from Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.rdb rename to Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.rdb diff --git a/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.rdx b/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.rdx new file mode 100644 index 0000000..765c834 Binary files /dev/null and b/Lesson5_rmd_cache/html/unnamed-chunk-4_3114bb498722b8c7119d62ecb1bbcfee.rdx differ diff --git a/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.RData b/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.RData deleted file mode 100644 index e05417d..0000000 Binary files a/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.RData and /dev/null differ diff --git a/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.rdx b/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.rdx deleted file mode 100644 index c203114..0000000 Binary files a/Lesson5_rmd_cache/html/unnamed-chunk-4_c80d74384c6279d65b0848a1c32fb929.rdx and /dev/null differ diff --git a/docs/Lesson1.html b/docs/Lesson1.html index 0badf02..cc171b6 100644 --- a/docs/Lesson1.html +++ b/docs/Lesson1.html @@ -429,6 +429,9 @@
  • Lesson 6 +
  • +
  • + Lesson 7