Skip to content

Commit 5c9a13a

Browse files
Merge pull request #53 from miraisolutions/feature/26-revise-git-modified-date
Revise document path for Git modified date child document
2 parents 51098d3 + 57fbb83 commit 5c9a13a

7 files changed

+24
-49
lines changed

index.Rmd

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ output:
2626

2727
# Introduction {-}
2828

29-
```{bash mod-date, engine.opts='-l', echo=FALSE, comment=""}
30-
printf "Last modified: %s" "$(git log -1 --format=%cd index.Rmd | sed 's/^[^ ]* //;s/ [^ ]*$//')"
29+
```{r mod-date, eval=TRUE, echo=FALSE, results='asis'}
30+
mod_date_envir <- list2env(list(knitr_current_input = knitr::current_input()))
31+
cat(knitr::knit_child("mod-date.Rmd", quiet = TRUE, envir = mod_date_envir))
3132
```
3233

3334
[**Mirai Solutions**](https://mirai-solutions.ch/) is a Zurich-based software development and consultancy firm, delivering cutting-edge technology and best practices to the industry, helping companies elevate their data analytics and operations.

mod-date.Rmd

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
```{bash mod-date, engine.opts='-l', echo=FALSE}
2-
printf "Last modified: %s" "$(git log -1 --format=%cd $(cat tg-temp.txt) | sed 's/^[^ ]* //;s/ [^ ]*$//')"
1+
```{r mod-date-setenv, eval=TRUE, include=FALSE}
2+
Sys.setenv(KNITR_CURRENT_INPUT = knitr_current_input)
3+
```
4+
5+
```{bash mod-date-print, engine.opts='-l', eval=TRUE, echo=FALSE, comment="", message=FALSE}
6+
printf "Last modified: %s" "$(git log -1 --format=%cd $KNITR_CURRENT_INPUT | sed 's/^[^ ]* //;s/ [^ ]*$//')"
37
```

renv.Rmd

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, eval = FALSE)
55
```
66

7-
```{r topic-envvar, include = FALSE, eval=TRUE}
8-
cat(knitr::current_input(), file="tg-temp.txt")
9-
```
10-
11-
```{r mod-date, child=c('mod-date.Rmd'), comment="", eval=TRUE}
12-
```
13-
14-
```{r envvar-unlink, include = FALSE, eval=TRUE}
15-
unlink("tg-temp.txt")
7+
```{r mod-date, eval=TRUE, echo=FALSE, results='asis'}
8+
mod_date_envir <- list2env(list(knitr_current_input = knitr::current_input()))
9+
cat(knitr::knit_child("mod-date.Rmd", quiet = TRUE, envir = mod_date_envir))
1610
```
1711

1812
For production readiness --- and project safety --- it is important to control the dependencies of a piece of development. This can be done at project level using the package [`renv`](https://rstudio.github.io/renv/).

roxygen-guidelines.Rmd

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ knitr::opts_chunk$set(
77
)
88
```
99

10-
```{r topic-envvar, include = FALSE, eval=TRUE}
11-
cat(knitr::current_input(), file="tg-temp.txt")
12-
```
13-
14-
```{r mod-date, child=c('mod-date.Rmd'), comment="", eval=TRUE}
15-
```
16-
17-
```{r envvar-unlink, include = FALSE, eval=TRUE}
18-
unlink("tg-temp.txt")
10+
```{r mod-date, eval=TRUE, echo=FALSE, results='asis'}
11+
mod_date_envir <- list2env(list(knitr_current_input = knitr::current_input()))
12+
cat(knitr::knit_child("mod-date.Rmd", quiet = TRUE, envir = mod_date_envir))
1913
```
2014

2115
The scope of this document is to provide *opinionated yet motivated

shiny-ci-cd.Rmd

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, eval = FALSE)
55
```
66

7-
```{r topic-envvar, include = FALSE, eval=TRUE}
8-
cat(knitr::current_input(), file="tg-temp.txt")
9-
```
10-
11-
```{r mod-date, child=c('mod-date.Rmd'), comment="", eval=TRUE}
12-
```
13-
14-
```{r envvar-unlink, include = FALSE, eval=TRUE}
15-
unlink("tg-temp.txt")
7+
```{r mod-date, eval=TRUE, echo=FALSE, results='asis'}
8+
mod_date_envir <- list2env(list(knitr_current_input = knitr::current_input()))
9+
cat(knitr::knit_child("mod-date.Rmd", quiet = TRUE, envir = mod_date_envir))
1610
```
1711

1812
It is good practice to integrate and develop an R Shiny app as an R package, to take full advantage of all the integrated features established for R packages (e.g., documentation, package namespaces, automated testing, `R CMD check`, etc.). A typical development workflow to package a Shiny app is provided by the [`golem` package](https://cran.r-project.org/web/packages/golem/index.html). Later in this chapter we will also indicate how to package a shiny app without the infrastructure provided by `golem`.

version-stable-r-development.Rmd

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, eval = FALSE)
66
```
77

8-
```{r topic-envvar, include = FALSE, eval=TRUE}
9-
cat(knitr::current_input(), file="tg-temp.txt")
10-
```
11-
12-
```{r mod-date, child=c('mod-date.Rmd'), comment="", eval=TRUE}
13-
```
14-
15-
```{r envvar-unlink, include = FALSE, eval=TRUE}
16-
unlink("tg-temp.txt")
8+
```{r mod-date, eval=TRUE, echo=FALSE, results='asis'}
9+
mod_date_envir <- list2env(list(knitr_current_input = knitr::current_input()))
10+
cat(knitr::knit_child("mod-date.Rmd", quiet = TRUE, envir = mod_date_envir))
1711
```
1812

1913
In the context of productive solutions, it is essential to have full control

xlconnect.Rmd

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, eval = FALSE)
55
```
66

7-
```{r topic-envvar, include = FALSE, eval=TRUE}
8-
cat(knitr::current_input(), file="tg-temp.txt")
9-
```
10-
11-
```{r mod-date, child=c('mod-date.Rmd'), comment="", eval=TRUE}
12-
```
13-
14-
```{r envvar-unlink, include = FALSE, eval=TRUE}
15-
unlink("tg-temp.txt")
7+
```{r mod-date, eval=TRUE, echo=FALSE, results='asis'}
8+
mod_date_envir <- list2env(list(knitr_current_input = knitr::current_input()))
9+
cat(knitr::knit_child("mod-date.Rmd", quiet = TRUE, envir = mod_date_envir))
1610
```
1711

1812
MS Excel is probably the most used support to share data analysis and reports in enterprise. Despite its popularity, performing data analysis within an Excel workbook can be cumbersome as well as error prone due to irreproducibility. A possible way out is to perform most of the steps of your data analysis and reporting in another programming language, such as R, and just present and share the results in Excel.

0 commit comments

Comments
 (0)