Skip to content

Commit

Permalink
Adding stuff about calling multi-software code
Browse files Browse the repository at this point in the history
  • Loading branch information
larsvilhuber authored Jun 26, 2024
1 parent 4a74bbb commit 0672765
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
43 changes: 43 additions & 0 deletions 90-multi-software.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Multi-software projects

Many projects will use multiple softwares, along the lines of "use what is appropriate for specific tasks." This may pose particular challenges. I showed that a generic `bash` script can handle running multiple softwares in the right sequence, but some researchers may be more comfortable in a main software package, or may not want to incur the additional complication of relying on `bash`, or worse, restricting reproducibility to a particular platform, for instance by choosing `cmd.exe` (`.bat` files) or Powershell scripts.

## Calling software A from within software B

In order to call external software from within a statistical programming language, it is necessary to know where, on a system, the software can be found. In "Environments", we discussed *search paths*, but in many computing environments, not each piece of software is on that search path.

However, it is possible to explicitly address this. Each software does know where it is installed. In R,

```R
R.home("bin")
```

will yield the location of the `R` executable, for instance
`C:/Program Files/R/R-4.4.0/bin/x64/R`. Note that it will vary by version!

Typing

```bash
where python
```

into a Bash or Zsh terminal (and appropriate commands in Powershell) might yield `C:/Program Files/Python312/python.exe` on a particular windows system. This can then be used, for instance, to call `R` and `python` from a Stata program:

```stata
global Rterm_path "C:\Program Files\R\R-4.3.1\bin\x64"
* Set path to python executable here:
global python_ex "C:\Program Files\Python312\python.exe"
ssc install rsource
ssc install python
python set exec "$python_ex"
python script "code/run_geo_clean.py"
rsource using "code/figure1.R"
```

where the Stata packages [`python`](https://ideas.repec.org/c/boc/bocode/s457688.html) and [`rsource`](https://ideas.repec.org/c/boc/bocode/s456847.html) are used.[^pythonstata]

[^pythonstata]: Note that Stata has [integrated Python functionality](https://www.stata.com/manuals/ppystataintegration.pdf) since version 16. The example referenced uses an older Stata package that works for Stata since 2013.
3 changes: 3 additions & 0 deletions 91-big-data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Big data and testing

(coming)
3 changes: 3 additions & 0 deletions 92-long-computation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Long computations and testing

(coming)
5 changes: 5 additions & 0 deletions _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ parts:
- file: 71-have-an-undergrad-run-it
- file: 72-virtual_machines
- file: 80-docker
- caption: More complex setups
chapters:
- file: 90-multi-software
- file: 91-big-data
- file: 92-long-computation

0 comments on commit 0672765

Please sign in to comment.