diff --git a/04-02-creating_log_files_automatically.md b/04-02-creating_log_files_automatically.md
index 548dfcd..78ee6b5 100644
--- a/04-02-creating_log_files_automatically.md
+++ b/04-02-creating_log_files_automatically.md
@@ -27,18 +27,52 @@ On Windows, follow instructions [here](https://www.stata.com/manuals/gswb.pdf#gs
::::{tab-item} R
-To automatically create a log file, run R from the command line as follows:
+To automatically create a log file, run R from the command line using the `BATCH` functionality, as follows:
```bash
-R CMD BATCH main.R
+R CMD BATCH options infile outfile
+```
+
+where
+
+- `options` are optional _options_ from the command R
+
+- `infile` is the required input file with the code to be executed
+
+- `outfile` is the name of an optional output file. If no output file
+is provided, the name of `infile` is taken as default, appending
+the extension `.Rout` to it.
+
+
+:::{warning}
+On Windows, you may need to include the full path of R: `C:\Program Files\R\R-4.1.0\bin\R.exe CMD BATCH main.R`
+:::
+
+
+This will create a file `main.Rout` in the same directory as `main.R`. If you prefer a different name for the output file, you can specify it.
+
+```bash
+R CMD BATCH main.R main.$(date +%F-%H:%M:%S).Rout
+```
+
+which will create a second-precise date-time stamped log file. Finally, if you want to prevent R from saving or restoring its environment (by default, `R CMD BATCH` does both), you can specify the `--no-save` and `--no-restore` options.
+
+```bash
+R CMD BATCH --no-save --no-restore main.R main.$(date +%F-%H:%M:%S).Rout
```
-will create a file `main.Rout` in the same directory as `main.R`.
:::{warning}
If there are other commands, such as `sink()`, active in the R code, the `main.Rout` file will not contain some output.
:::
+
+> To see more information, check the manual documentation by typing
+`?BATCH` (or `help(BATCH)`) from within an R interactive session. Or by
+typing `R CMD BATCH --help` from the command line.
+
+
+
::::
::::{tab-item} MATLAB
diff --git a/presentation/04-creating_log_files.md b/presentation/04-creating_log_files.md
index 9cd4d84..f498801 100644
--- a/presentation/04-creating_log_files.md
+++ b/presentation/04-creating_log_files.md
@@ -120,15 +120,14 @@ log using "`globallog'", name(global) replace text
- While some software (Stata, MATLAB) will create log files that contain **commands and output**, others (R, Python) will create log files that contain **only output**.
-### Creating log files automatically
+# Creating log files automatically
An alternative (or complement) to creating log files explicitly is to use native functionality of the software to create them. This usually is triggered when using the command line to run the software, and thus may be considered an **advanced topic.** The examples below are for Linux/macOS, but similar functionality exists for Windows.
-:::: {.panel-tabset}
-### Stata
+## Stata
To automatically create a log file, run Stata from the command line with the `-b` option:
@@ -138,30 +137,112 @@ stata -b do main.do
which will create a file `main.log` in the same directory as `main.do`.
-```{.notes}
-For this to work, the filename cannot include spaces.
+> - For this to work, the filename cannot include spaces.
+> - On Windows, follow instructions [here](https://www.stata.com/manuals/gswb.pdf#gswB.5).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## R {auto-animate=true transition="fade"}
+
+To automatically create a log file, run R from the command line using the `BATCH` functionality, as follows:
+
+```bash
+R CMD BATCH options infile outfile
+```
+
+> On Windows, you may need to include the full path of R:
+
```
-On Windows, follow instructions [here](https://www.stata.com/manuals/gswb.pdf#gswB.5).
+C:\Program Files\R\R-4.1.0\bin\R.exe CMD BATCH main.R
+```
+
+
+## R {auto-animate=true transition="fade"}
+To automatically create a log file, run R from the command line using the `BATCH` functionality, as follows:
+```bash
+R CMD BATCH options infile outfile
+```
-### R
+This will create a file `main.Rout` in the same directory as `main.R`.
-To automatically create a log file, run R from the command line as follows:
+## R {auto-animate=true transition="fade"}
+
+If you prefer a different name for the output file, you can specify it.
```bash
-R CMD BATCH main.R
+R CMD BATCH main.R main.$(date +%F-%H:%M:%S).Rout
```
-will create a file `main.Rout` in the same directory as `main.R`.
+which will create a second-precise date-time stamped log file.
-```{.notes}
-If there are other commands, such as `sink()`, active in the R code, the `main.Rout` file will not contain some output.
+## R {auto-animate=true transition="fade"}
+
+If you want to prevent R from saving or restoring its environment (by default, `R CMD BATCH` does both), you can specify the `--no-save` and `--no-restore` options.
+
+```bash
+R CMD BATCH --no-save --no-restore main.R main.$(date +%F-%H:%M:%S).Rout
```
+## R {.smaller}
+
+:::{warning}
+If there are other commands, such as `sink()`, active in the R code, the `main.Rout` file will not contain some output.
+:::
+
+## R {.smaller}
+
+> To see more information, check the manual documentation by typing
+`?BATCH` (or `help(BATCH)`) from within an R interactive session. Or by
+typing `R CMD BATCH --help` from the command line.
+
+
+
+
+
+
+
+
+
+
+
+
+
-### MATLAB
+
+
+
+
+
+
+
+
+
+
+
+
+## MATLAB {auto-animate=true}
To automatically create a log file, run MATLAB from the command line as follows:
@@ -169,6 +250,8 @@ To automatically create a log file, run MATLAB from the command line as follows:
matlab -nodisplay -r "addpath(genpath('.')); main" -logfile matlab.log
```
+## MATLAB {auto-animate=true transition="fade"}
+
A similar command on Windows would be:
```bash
@@ -177,7 +260,7 @@ start matlab -nosplash -minimize -r "addpath(genpath('.'));main" -logfile mat
-### Julia, Python
+## Julia, Python {auto-animate=true transition="fade"}
In order to capture screen output in Julia and Python, on Unix-like system (Linux, macOS), the following can be run:
@@ -185,7 +268,11 @@ In order to capture screen output in Julia and Python, on Unix-like system (Linu
julia main.jl | tee main.log
```
-or
+which will create a log file with everything that would normally appear on the console using the `tee` command.
+
+## Julia, Python {auto-animate=true transition="fade"}
+
+In order to capture screen output in Julia and Python, on Unix-like system (Linux, macOS), the following can be run:
```bash
python main.py | tee main.log
@@ -193,7 +280,6 @@ python main.py | tee main.log
which will create a log file with everything that would normally appear on the console using the `tee` command.
-::::
diff --git a/presentation/index.html b/presentation/index.html
index f34e419..e0f28e9 100644
--- a/presentation/index.html
+++ b/presentation/index.html
@@ -8,7 +8,7 @@
-
+
@@ -43,7 +43,7 @@
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
- pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
+ pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
@@ -418,7 +418,7 @@
Day T-1
Introduction
-
This document describes a few possible steps to self-check replication packages before submitting them to a journal. It is not meant to be exhaustive, and it is not meant to be prescriptive. There are many ways to construct a replication package, and many more to check that it works.
+
This document describes a few possible steps to self-check replication packages before submitting them to a journal. It is not meant to be exhaustive, and it is not meant to be prescriptive. There are many ways to construct a replication package, and many more to check that it works.
Computational Empathy
@@ -466,8 +466,7 @@
Why
-
-
+
@@ -603,8 +602,7 @@
Stata
do$rootdir/04_figures.do* Run the appendix filedo$rootdir/05_appendix.do
-
-
+
Stata
@@ -624,8 +622,7 @@
Stata
do$rootdir/04_figures.do* Run the appendix filedo$rootdir/05_appendix.do
-
-
+
Notes
@@ -645,8 +642,7 @@
Notes
cd /where/my/code/isstata-mp-b do main.do
where stata-mp should be replaced with stata or stata-se depending on your licensed version.
-
-
+
R
@@ -672,8 +668,7 @@
R
source(file.path(rootdir, "04_figures.R"), echo =TRUE)## Run the appendix filesource(file.path(rootdir, "05_appendix.R"), echo =TRUE)
-
-
+
R
@@ -699,8 +694,7 @@
R
source(file.path(rootdir, "04_figures.R"), echo =TRUE)## Run the appendix filesource(file.path(rootdir, "05_appendix.R"), echo =TRUE)
-
-
+
While some software (Stata, MATLAB) will create log files that contain commands and output, others (R, Python) will create log files that contain only output.
-
Creating log files automatically
+
+
+
+
Creating log files automatically
An alternative (or complement) to creating log files explicitly is to use native functionality of the software to create them. This usually is triggered when using the command line to run the software, and thus may be considered an advanced topic. The examples below are for Linux/macOS, but similar functionality exists for Windows.
To automatically create a log file, run R from the command line using the BATCH functionality, as follows:
+
R CMD BATCH options infile outfile
+
This will create a file main.Rout in the same directory as main.R.
+
+
+
R
+
If you prefer a different name for the output file, you can specify it.
+
R CMD BATCH main.R main.$(date +%F-%H:%M:%S).Rout
+
which will create a second-precise date-time stamped log file.
+
+
+
R
+
If you want to prevent R from saving or restoring its environment (by default, R CMD BATCH does both), you can specify the --no-save and --no-restore options.
+
R CMD BATCH --no-save--no-restore main.R main.$(date +%F-%H:%M:%S).Rout
+
+
+
R
+
+
If there are other commands, such as sink(), active in the R code, the main.Rout file will not contain some output.
-
+
+
+
R
+
+
To see more information, check the manual documentation by typing ?BATCH (or help(BATCH)) from within an R interactive session. Or by typing R CMD BATCH --help from the command line.
+
+
+
+
MATLAB
To automatically create a log file, run MATLAB from the command line as follows:
The default set of directories which can be searched, from a freshly installed Stata, can be queried with the sysdir command, and will look something like this:
To look for a command, Stata will look in the first directory, then the second, and so on, until it finds it. If it does not find it, it will return an error.
-
which reghdfe
+
which reghdfe
command reghdfe not found as either built-in or ado-file
r(111);
-
-
+
Where are packages installed?
@@ -1184,32 +1211,30 @@
Where are packages installed?
When we install a package (net install, ssc install)4, only one of the (sysdir) paths is relevant: PLUS.
. ssc install reghdfe
-checking reghdfe consistency and verifying not already installed...
-installing into C:\Users\lv39\ado\plus\...
-installation complete.
-
-. which reghdfe
-C:\Users\lv39\ado\plus\r\reghdfe.ado
-*! version 6.12.3 08aug2023
-
-
+
. ssc install reghdfe
+checking reghdfe consistency and verifying not already installed...
+installing into C:\Users\lv39\ado\plus\...
+installation complete.
+
+. which reghdfe
+C:\Users\lv39\ado\plus\r\reghdfe.ado
+*! version 6.12.3 08aug2023
+
Using environments in Stata
@@ -1217,66 +1242,63 @@
Using environments in Stata
But the (PLUS) directory can be manipulated
-
* Set the root directory
-global rootdir : pwd
-* Define a location where we will holdall packages in THIS project (the "environment")
-global adodir "$rootdir/ado"
-* make sure it exists, ifnot create it.
-cap mkdir"$adodir"
-* Now let's simplify the adopath
-* - remove the OLDPLACE and PERSONAL paths
-* - NEVER REMOVE THE SYSTEM-WIDE PATHS - bad things will happen!
-adopath - OLDPLACE
-adopath - PERSONAL
-* modify the PLUS path to point to our new location, and move it up in the order
-sysdirsetPLUS"$adodir"
-adopath ++ PLUS
-* verify the path
-adopath
-
-
+
* Set the root directory
+global rootdir : pwd
+* Define a location where we will holdall packages in THIS project (the "environment")
+global adodir "$rootdir/ado"
+* make sure it exists, ifnot create it.
+cap mkdir"$adodir"
+* Now let's simplify the adopath
+* - remove the OLDPLACE and PERSONAL paths
+* - NEVER REMOVE THE SYSTEM-WIDE PATHS - bad things will happen!
+adopath - OLDPLACE
+adopath - PERSONAL
+* modify the PLUS path to point to our new location, and move it up in the order
+sysdirsetPLUS"$adodir"
+adopath ++ PLUS
+* verify the path
+adopath
+
Using environments in Stata
-
* Set the root directory
-global rootdir : pwd
-* Define a location where we will holdall packages in THIS project (the "environment")
-global adodir "$rootdir/ado"
-* make sure it exists, ifnot create it.
-cap mkdir"$adodir"
-* Now let's simplify the adopath
-* - remove the OLDPLACE and PERSONAL paths
-* - NEVER REMOVE THE SYSTEM-WIDE PATHS - bad things will happen!
-adopath - OLDPLACE
-adopath - PERSONAL
-* modify the PLUS path to point to our new location, and move it up in the order
-sysdirsetPLUS"$adodir"
-adopath ++ PLUS
-* verify the path
-adopath
+
* Set the root directory
+global rootdir : pwd
+* Define a location where we will holdall packages in THIS project (the "environment")
+global adodir "$rootdir/ado"
+* make sure it exists, ifnot create it.
+cap mkdir"$adodir"
+* Now let's simplify the adopath
+* - remove the OLDPLACE and PERSONAL paths
+* - NEVER REMOVE THE SYSTEM-WIDE PATHS - bad things will happen!
+adopath - OLDPLACE
+adopath - PERSONAL
+* modify the PLUS path to point to our new location, and move it up in the order
+sysdirsetPLUS"$adodir"
+adopath ++ PLUS
+* verify the path
+adopath
Prepare a confidential (partial) replication packageproject-confidential.zip, contains the contents of data/confidential and possibly data/conf_analysis.
Important: the package contains all code, including the code that is used to process the confidential data!
+
Prepare a confidential (partial) replication packageproject-confidential.zip, contains the contents of data/confidential and possibly data/conf_analysis.