From acb839ae126e824e7395a2280b03f2681de00c45 Mon Sep 17 00:00:00 2001 From: Murray Logan Date: Sun, 28 Jul 2024 10:43:29 +1000 Subject: [PATCH] Add more --- .github/workflows/tut-build-publish.yml | 2 +- pres/10_pres_git.qmd | 129 +++++++++++++++++++++ pres/resources/RStudio_GitAdd_combined.png | Bin 36394 -> 36378 bytes resources/pres-style.css | 8 +- 4 files changed, 136 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tut-build-publish.yml b/.github/workflows/tut-build-publish.yml index dd89f4c6..d712ad59 100644 --- a/.github/workflows/tut-build-publish.yml +++ b/.github/workflows/tut-build-publish.yml @@ -33,7 +33,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev make + sudo apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev make ImageMagick # install graphviz - name: Install Graphviz diff --git a/pres/10_pres_git.qmd b/pres/10_pres_git.qmd index add13fc5..ba00d0ca 100644 --- a/pres/10_pres_git.qmd +++ b/pres/10_pres_git.qmd @@ -8,6 +8,7 @@ format: embed-resources: true auto-stretch: false css: ../resources/pres-style.css + margin: 0 output_dir: "docs" bibliography: ../resources/references.bib --- @@ -1426,4 +1427,132 @@ magick resources/RStudio_NewProject3a.png -resize 250x resources/RStudio_NewProj ![](resources/RStudio_NewProject2a_small.png) ![](resources/RStudio_NewProject3a_small.png) +### R +```{r create_package, results='markdown', eval=FALSE} +library(usethis) +create_project(path='~/path/project_name', rstudio=TRUE) +use_git() +``` + + + +Git - adding content +---------------------- + +
+ +Create a file (text, code etc)

+ +- those using R, call it **analysis.R** + +```{r, engine='R',results="markup", prompt=FALSE,eval=FALSE} +x=seq(1, 10, len = 1) +y=40 * 2 + rnorm(10, 0, 5) +plot(x, y) +``` + +

+ +Otherwise, create any kind of file (**in the folder we just created**) + +```{r, engine='bash',results="markup", prompt=FALSE,eval=TRUE, echo=FALSE} +cd ~/tmp/Test_repo +echo 'x=seq(1, 10, len = 1)' > analysis.R +echo 'y=40 * 2 + rnorm(10, 0, 5)' >> analysis.R +echo 'plot(x, y)' >> analysis.R +``` + +Git - adding content +---------------------- + +Stage the changes (**add**) + +```{r, engine='bash',results="markup", prompt=FALSE,eval=FALSE,echo=TRUE} +git add +``` +For example: +```{r, engine='bash',results="markup", prompt=FALSE,eval=TRUE,echo=-1} +cd ~/tmp/Test_repo +git add analysis.R +``` +### RStudio + +```{bash, echo=FALSE, eval=TRUE} +magick resources/RStudio_AddFile.png -resize 400x resources/RStudio_AddFile_small.png +magick resources/RStudio_GitStatus.png -resize 300x resources/RStudio_GitStatus_small.png +magick resources/RStudio_GitAdd.png -resize 300x resources/RStudio_GitAdd_small.png + +magick resources/RStudio_GitStatus.png resources/RStudio_GitAdd.png -append resources/RStudio_GitAdd_combined.png +``` + +![](resources/RStudio_AddFile_small.png){width=40%} +![](resources/RStudio_GitAdd_combined.png){width=30%} + +```{r gert_add, results='markdown', eval=FALSE} +gert::git_add('analysis.R') +``` + +Git - adding content +---------------------- + +```{r, engine='bash',results="hide", prompt=FALSE,eval=TRUE, echo=FALSE} +../resources/git-draw --image-only --sha1-length 5 --hide-legend --hide-reflogs --git-dir ~/tmp/Test_repo/.git --image-filename resources/Test_repo0.png +``` + +```{tikz Fig0b, engine='tikz',cache=TRUE,fig.show='hide',eval=TRUE, echo=FALSE,engine.opts = list(template = "../resources/tikz.tex"), fig.width=6} +``` +![](resources/Test_repo0.png) + + +Git - .gitignore +------------------ + +### RStudio + +```{bash, echo=FALSE, eval=TRUE} +magick resources/RStudio_gitignore.png -resize 350x resources/RStudio_gitignore_small.png +magick resources/Rstudio_gitignore2.png -resize 350x resources/RStudio_gitignore2_small.png +``` +![](resources/RStudio_gitignore_small.png) +![](resources/RStudio_gitignore2_small.png) + +Examples + +- `.RData` all files ending in .RData +- `.pdf` all files ending in .pdf +- `data/` the entire folder called data + + + +Git - committing +---------------------- + +```{r, engine='bash',results="markup", prompt=FALSE,eval=TRUE, echo=-1} +cd ~/tmp/Test_repo +git commit -m 'Initial commit' +``` +```{r, engine='bash',results="hide", prompt=FALSE,eval=TRUE, echo=FALSE} +../resources/git-tikz --git-dir ~/tmp/Test_repo/.git --filename 10_pres_git_Test_repo1.tex +mv 10_pres_git_Test_repo1.pdf resources/10_pres_git_Test_repo1.pdf +``` + +### RStudio + + + +```{bash, echo=FALSE, eval=TRUE} +magick resources/RStudio_GitCommit.png -resize 400x resources/RStudio_GitCommit_small.png +magick -density 300 resources/10_pres_git_Test_repo1.pdf -resize 350x resources/10_pres_git_Test_repo1.png +``` +![](resources/RStudio_GitCommit_small.png) +![](resources/10_pres_git_Test_repo1.png) + +```{r gert_commit, results='markdown', eval=FALSE} +gert::git_commit('Initial commit') +``` diff --git a/pres/resources/RStudio_GitAdd_combined.png b/pres/resources/RStudio_GitAdd_combined.png index e518567b982261e1c916ba41e972bb3c98bcf84b..0293d037e2a93b1d66362e7a5c2cd332aef88733 100644 GIT binary patch delta 96 zcmZ2AhiTRvrU@z&O(MBou*)#0C@Qc0*06CpN3WELu7SC(k$H%bk(B`u8E6|A0Lg8P n+b>Ms+3T$ak+ui{iW-|)85={SH~fE`#Q+4Ju6{1-oD!M!lvQAWt;d;iyDlVyL@Z5R-#&(WgDI;A26I~;- z5JN*N6C*1_Q*8qSD+2>Hz4yl^uk7_!GtxB#sxS>PGPW`@wK6t_NE>wsYA^tSr>mdK II;Vst01(+8mjD0& diff --git a/resources/pres-style.css b/resources/pres-style.css index 7fcca3bc..6e1bd1be 100644 --- a/resources/pres-style.css +++ b/resources/pres-style.css @@ -62,8 +62,8 @@ padding-top:20px; padding-right:100px; font-family: VeteranTypewriter,Arial, serif; - font-size:30pt; - line-height: 15pt; + font-size:22pt; + line-height: 13pt; } .slides > .slide h2 { @@ -227,6 +227,10 @@ pre.r { /* margin: 0; */ overflow: unset !important; } +.reveal p { + padding-bottom: 2pt !important; + margin-bottom: 2pt !important; +} .reveal pre { width: inherit !important; }