Skip to content

Commit

Permalink
updated l5 rmd eg
Browse files Browse the repository at this point in the history
  • Loading branch information
darwinanddavis committed Oct 21, 2019
1 parent 06169fa commit f5f9cb7
Show file tree
Hide file tree
Showing 130 changed files with 6,312 additions and 97 deletions.
41 changes: 40 additions & 1 deletion .Rproj.user/ABE7B653/console06/E8FBF1BE
Original file line number Diff line number Diff line change
Expand Up @@ -1215,4 +1215,43 @@ remote:
To https://github.com/darwinanddavis/EmoRyCodingClub
5a6f108..d2418d2 master -> master
]0;~/Documents/Emory/admin/ecc6300L-127771-M:ecc malishev$ git pushcommit -m 'l6 yyaml'add .


]0;~/Documents/Emory/admin/ecc6300L-127771-M:ecc malishev$ git add .pushcommit -m 'l6 yyaml'''''' '
'r'e' n''d'e'r' 's'i't'e' 'l'6'
[master 06169fa] render site l6
30 files changed, 1943 insertions(+), 157 deletions(-)
rewrite Lesson5_files/figure-html/unnamed-chunk-3-1.png (66%)
create mode 100644 Lesson5_rmd.log
create mode 100644 Lesson5_rmd_files/figure-docx/unnamed-chunk-1-1.png
create mode 100644 Lesson5_rmd_files/figure-docx/unnamed-chunk-2-1.png
create mode 100644 Lesson5_rmd_files/figure-html/unnamed-chunk-1-1.png
create mode 100644 Lesson5_rmd_files/figure-html/unnamed-chunk-2-1.png
create mode 100644 Lesson5_rmd_files/figure-markdown_github/unnamed-chunk-1-1.png
create mode 100644 Lesson5_rmd_files/figure-markdown_github/unnamed-chunk-2-1.png
rewrite docs/Lesson3_files/figure-html/unnamed-chunk-2-1.png (97%)
delete mode 100644 docs/Lesson4_files/figure-html/unnamed-chunk-1-1.png
rewrite docs/Lesson5_files/figure-html/unnamed-chunk-3-1.png (66%)
create mode 100644 docs/Lesson5_rmd.docx
create mode 100644 docs/Lesson5_rmd.log
create mode 100644 docs/Lesson5_rmd.md
create mode 100644 docs/Lesson5_rmd.pdf
create mode 100644 docs/Lesson5_rmd_files/figure-docx/unnamed-chunk-1-1.png
create mode 100644 docs/Lesson5_rmd_files/figure-docx/unnamed-chunk-2-1.png
create mode 100644 docs/Lesson5_rmd_files/figure-markdown_github/unnamed-chunk-1-1.png
create mode 100644 docs/Lesson5_rmd_files/figure-markdown_github/unnamed-chunk-2-1.png
]0;~/Documents/Emory/admin/ecc6300L-127771-M:ecc malishev$ ig tpgit push
Counting objects: 35, done.
Delta compression using up to 4 threads.
Compressing objects: 3% (1/32) Compressing objects: 6% (2/32) Compressing objects: 9% (3/32) Compressing objects: 12% (4/32) Compressing objects: 15% (5/32) Compressing objects: 18% (6/32) Compressing objects: 21% (7/32) Compressing objects: 25% (8/32) Compressing objects: 28% (9/32) Compressing objects: 31% (10/32) Compressing objects: 34% (11/32) Compressing objects: 37% (12/32) Compressing objects: 40% (13/32) Compressing objects: 43% (14/32) Compressing objects: 46% (15/32) Compressing objects: 50% (16/32) Compressing objects: 53% (17/32) Compressing objects: 56% (18/32) Compressing objects: 59% (19/32) Compressing objects: 62% (20/32) Compressing objects: 65% (21/32) Compressing objects: 68% (22/32) Compressing objects: 71% (23/32) Compressing objects: 75% (24/32) Compressing objects: 78% (25/32) Compressing objects: 81% (26/32) Compressing objects: 84% (27/32) Compressing objects: 87% (28/32) Compressing objects: 90% (29/32) Compressing objects: 93% (30/32) Compressing objects: 96% (31/32) Compressing objects: 100% (32/32) Compressing objects: 100% (32/32), done.
Writing objects: 2% (1/35) Writing objects: 5% (2/35) Writing objects: 8% (3/35) Writing objects: 11% (4/35) Writing objects: 14% (5/35) Writing objects: 17% (6/35) Writing objects: 20% (7/35) Writing objects: 22% (8/35) Writing objects: 25% (9/35) Writing objects: 28% (10/35) Writing objects: 31% (11/35) Writing objects: 34% (12/35) Writing objects: 37% (13/35) Writing objects: 40% (14/35) Writing objects: 42% (15/35) Writing objects: 45% (16/35) Writing objects: 48% (17/35) Writing objects: 51% (18/35) Writing objects: 54% (19/35) Writing objects: 57% (20/35) Writing objects: 60% (21/35) Writing objects: 62% (22/35) Writing objects: 65% (23/35) Writing objects: 68% (24/35) Writing objects: 71% (25/35) Writing objects: 74% (26/35) Writing objects: 77% (27/35) Writing objects: 80% (28/35) Writing objects: 80% (28/35), 1.07 MiB | 230.00 KiB/s Writing objects: 82% (29/35), 1.07 MiB | 230.00 KiB/s Writing objects: 85% (30/35), 1.07 MiB | 230.00 KiB/s Writing objects: 88% (31/35), 1.07 MiB | 230.00 KiB/s Writing objects: 91% (32/35), 1.07 MiB | 230.00 KiB/s Writing objects: 94% (33/35), 1.07 MiB | 230.00 KiB/s Writing objects: 97% (34/35), 1.07 MiB | 230.00 KiB/s Writing objects: 100% (35/35), 1.07 MiB | 230.00 KiB/s Writing objects: 100% (35/35), 1.94 MiB | 230.00 KiB/s, done.
Total 35 (delta 15), reused 0 (delta 0)
remote: Resolving deltas: 0% (0/15)remote: Resolving deltas: 6% (1/15)remote: Resolving deltas: 13% (2/15)remote: Resolving deltas: 20% (3/15)remote: Resolving deltas: 26% (4/15)remote: Resolving deltas: 33% (5/15)remote: Resolving deltas: 40% (6/15)remote: Resolving deltas: 46% (7/15)remote: Resolving deltas: 53% (8/15)remote: Resolving deltas: 60% (9/15)remote: Resolving deltas: 66% (10/15)remote: Resolving deltas: 73% (11/15)remote: Resolving deltas: 80% (12/15)remote: Resolving deltas: 86% (13/15)remote: Resolving deltas: 93% (14/15)remote: Resolving deltas: 100% (15/15)remote: Resolving deltas: 100% (15/15), completed with 15 local objects.
remote:
remote: GitHub found 2 vulnerabilities on darwinanddavis/EmoRyCodingClub's default branch (2 moderate). To find out more, visit:
remote: https://github.com/darwinanddavis/EmoRyCodingClub/network/alerts
remote:
To https://github.com/darwinanddavis/EmoRyCodingClub
d2418d2..06169fa master -> master
]0;~/Documents/Emory/admin/ecc6300L-127771-M:ecc malishev$ peopen _site.yml
]0;~/Documents/Emory/admin/ecc6300L-127771-M:ecc malishev$ open _site.yml
]0;~/Documents/Emory/admin/ecc6300L-127771-M:ecc malishev$ git add .
Expand Down
1 change: 1 addition & 0 deletions .Rproj.user/ABE7B653/sources/prop/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2FLesson5.Rmd="6A63A69"
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2FLesson5_rmd.Rmd="76C81E37"
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2FLesson6.Rmd="1AA4DEB8"
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2FLesson7.Rmd="D245CEC4"
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2Fadmin%2F_ecc_master1.Rmd="D4A80BDA"
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2Fadmin%2Fecc_master1.Rmd="86A44BC0"
~%2FDocuments%2FEmory%2Fadmin%2Fecc%2Fadmin_%2Fairbnbdata_test.R="7160458D"
Expand Down
1 change: 1 addition & 0 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/Users/malishev/Documents/Emory/admin/ecc/Lesson5.Rmd="18E98FB2"
/Users/malishev/Documents/Emory/admin/ecc/Lesson5_rmd.Rmd="622DEF85"
/Users/malishev/Documents/Emory/admin/ecc/Lesson6.Rmd="2D08C0EF"
/Users/malishev/Documents/Emory/admin/ecc/Lesson7.Rmd="5F2E2BA4"
/Users/malishev/Documents/Emory/admin/ecc/admin/_ecc_master1.Rmd="ADA1EBE5"
/Users/malishev/Documents/Emory/admin/ecc/admin_/airbnbdata_test.R="DD9B31B9"
/Users/malishev/Documents/Emory/admin/ecc/admin_/atl_breweries.Rmd="3D591BD"
Expand Down
7 changes: 5 additions & 2 deletions Lesson5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
params:
lesson: "Lesson 5"
title: "Turning code into reproducible documents with `Rmarkdown`"
bookchapter_name: "Download the `RMarkdown` template here"
bookchapter_name: "Download the `RMarkdown` template here (right click > Save Link As")
bookchapter_section: "https://github.com/darwinanddavis/EmoRyCodingClub/raw/master/Lesson5_rmd.Rmd"
functions: "`here`, `summarise`"
packages: "`here`, `set_here`, `dr_here`, `dplyr`"
Expand Down Expand Up @@ -141,6 +141,7 @@ Have a look through each section of the raw `.Rmd` file to see what the code doe

# Exercises

* Knit a PDF, HTML, and Word doc. Use the hotkey `Cmd/Ctrl + Shift + K`
* Create a 'EmoRy Coding Club notes' document (PDF or HTML document)
* Create your own parameter in the yaml
* Create a code chunk that shows the code and output, but masks any warnings
Expand All @@ -154,7 +155,9 @@ url <- "http://data.insideairbnb.com/united-states/ny/new-york-city/2019-06-02/d
nyc_full <- read_csv(url) # reads in data
nyc_full %>% glimpse
```
* Change the above figure dimensions in the knitted document
* Change the above figure dimensions in the knitted document
* Create a table with the title in bold text and one of the rows italicised
* Write an inline equation and a idented equation


<!-- end body -->
Expand Down
126 changes: 103 additions & 23 deletions Lesson5_rmd.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ 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
Expand All @@ -21,13 +14,28 @@ output:
fig_width: 4
fig_height: 5
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
pandoc_args: --smart
toc: yes
md_document: # markdown options
variant: markdown_github
inludes:
before_body: before_body.tex
subtitle:
tags:
- nothing
- nothingness
params:
email: "your email here"
date: !r Sys.Date()
Expand All @@ -40,7 +48,7 @@ classoption: portrait
MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } });
</script>

```{r, set-options, echo = F, cache = F}
```{r, set-options, echo = F, cache = T}
options(width=100)
knitr::opts_chunk$set(
eval = TRUE, # run all code
Expand All @@ -51,6 +59,15 @@ knitr::opts_chunk$set(
size="small" # set code chunk size
)
### run this once
# tinytex::install_tinytex()
packages <- c("DT","htmlwidgets")
ppp <- lapply(packages,require,character.only=T)
names(ppp) <- packages
if(any(ppp==F)){cbind(packages,ppp);cat("\n\n\n ---> Check packages are loaded properly <--- \n\n\n")}
# knitr::opts_knit$set(root.dir=paste0(params$dir,"/")) # set working dir
# setwd(paste0(params$dir,"/")) # for running just in R not knitr
```
Expand All @@ -67,36 +84,50 @@ R version: `r params$version`

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](https://github.com/darwinanddavis).

Make footnotes^[Where the footnote goes here and it is automatically formatted].
Make footnotes^[Here is the footnote you created earlier, automatically formatted].

## Use different headings
# You can easily create headings. This is the same font size as the 'Overview' above

## Then move down in font size

### Like this subheading

# Just like \LaTeX{}, but _more versatile_.
#### And this fourth order heading

Insert line breaks <br> 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,
<!-- To do this, place the cursor on the text and type 'Cmd/Ctl + Shift + C' -->

\newpage

\newpage

## 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)$
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)$ (from^[Efthimiades, S., Physical meaning and derivation of Schrodinger and Dirac equations, Department of Natural Sciences, Fordham University. [doi: d34464566](https://arxiv.org/vc/quant-ph/papers/0607/0607001v1.pdf).])

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

## Embed images/gifs:
Expand Down Expand Up @@ -148,7 +179,7 @@ Figure 2. Example of a plot with improved graphics and its associated code embed
Table 1. Definitions of model parameters for individual hosts and **parasites**. Dimensions and units: -, dimensionless; cm, centimetres; J, Joules; L, length.

| Parameter | Definition | Dimension<br/>(unit) |
| :---: | :--- | :---: |
| :---: | :--- | ---: |
| _L_ | structural length | cm |
| _ee_ | scaled reserve density | J (cm^3^) |
| _D_ | host development | --- |
Expand All @@ -157,6 +188,47 @@ Table 1. Definitions of model parameters for individual hosts and **parasites**.
\newpage



## Use buttons or tabs for sub-chapters {.tabset .tabset-fade .tabset-pills}

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

```{r,echo=F}
require(ggplot2)
require(plotly)
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))) +
labs(x = "Random normally distributed data",
y = "Sampled integers") +
theme_minimal()
ggplotly(p)
```

### More tables
Here's a new way of creating tables using the `DT` package

```{r,cache=T,warning=F, echo=F}
require(DT)
require(htmlwidgets)
datatable(mtcars,
rownames = T,
filter="top",
options = list(pageLength = 5, scrollX=T),
class = 'cell-border stripe',
editable = 'cell',
caption = "Table 1. The 'mtcars' dataset presented in a datatable. Try editing the columns and cells."
)
```


***

## Embed code from different languages

### This is `R` code
Expand Down Expand Up @@ -209,8 +281,16 @@ x = A \ b # Solve the system Ax = b

### CSS
```{css, eval=F}
body {
color: red;
# 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;
}
```

Expand Down
8 changes: 8 additions & 0 deletions Lesson5_rmd_cache/html/__packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
base
viridisLite
viridis
ggplot2
plotly
DT
htmlwidgets
nycflights13
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Lesson5_rmd_files/figure-docx/unnamed-chunk-1-1.png
Binary file not shown.
Binary file removed Lesson5_rmd_files/figure-docx/unnamed-chunk-2-1.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 6 additions & 6 deletions Lesson6.Rmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
params:
lesson: "Lesson 6"
title: "Applying functions with `purrr`"
title: "Lists, lists, lists and applying functions with `purrr`"
bookchapter_name: "Cheat sheet for the `purrr` package"
bookchapter_section: "https://purrr.tidyverse.org/"
functions: "`map`, `map2`"
Expand Down Expand Up @@ -68,7 +68,7 @@ Use the `purrr` package to apply functions to lists and vectors.

# Do First

Recreate the below plot using the smaller NYC Airbnb dataset. To change the legend title, add the (unintuitive) `colour = "your legend text"` argument to the `labs()` function.
Recreate the below plot using the smaller NYC Airbnb dataset. The curve is a 'loess'. To change the legend title, add the (unintuitive) `colour = "your legend title"` argument to the `labs()` function.

```{r}
# smaller csv file (16 cols)
Expand All @@ -78,9 +78,7 @@ nyc <- nyc[nyc$id < 1000000,] # get smaller subet of data
```

```{r, echo=F, eval=T, out.width="100%"}
require(ggthemes)
require(ggplot2)
require(readr)
require(ggthemes,ggplot2,readr)
# smaller csv file (16 cols)
url <- "http://data.insideairbnb.com/united-states/ny/new-york-city/2019-06-02/visualisations/listings.csv"
Expand Down Expand Up @@ -130,7 +128,9 @@ map2(ls1,ls2,sum)
`head_while` Return head elements until one does not pass. Also `tail_while`.

```{r,eval=F}
pluck(ls1,1)
pluck(ls1,3) # advantage = returns numeric
ls1[3][[1]] # this is the same as above
keep(ls2, is.na)
discard(ls1, is.na)
compact(ls1)
Expand Down
Loading

0 comments on commit f5f9cb7

Please sign in to comment.