-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
92 lines (68 loc) · 2.35 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(locatexec)
```
# locatexec
<!-- badges: start -->
[![R build status](https://github.com/ardata-fr/locatexec/workflows/R-CMD-check/badge.svg)](https://github.com/ardata-fr/locatexec/actions)
<!-- badges: end -->
The package aims to allow the localization of external programs such as
"python", "Google Chrome", "node.js" and "LibreOffice" in order to be able to
easily call them from R.
This makes it easier to call these programs from R from various operating
systems.
```{r}
library(locatexec)
if(exec_available("node")){
message(exec_version("node"))
message(node_exec())
}
```
```{r echo=FALSE}
execs <- c("node", "chrome", "python", "libreoffice", "excel", "powerpoint",
"pip", "firefox", "npm", "word")
exec_cmd <- paste0(execs, "_exec")
dat <- data.frame(
exec = execs,
exec_fun = paste0("`", exec_cmd, "()`"),
available = vapply(execs, exec_available, FUN.VALUE = FALSE),
version = vapply(execs, function(exec) format(exec_version(exec)), FUN.VALUE = NA_character_),
stringsAsFactors = FALSE, row.names = NULL)
path <- character(nrow(dat))
path[dat$available] <- sapply(
exec_cmd[dat$available],
function(cmd){
do.call(cmd, list())
})
path[!dat$available] <- NA_character_
dat$path <- path
knitr::kable(dat)
```
## Motivations
This was motivated by the need for tools
similar to `rmarkdown::pandoc_available()` and `rmarkdown::pandoc_exec()` but
allowing to locate external programs other than `pandoc`.
I need to use these programs from R without having heavy dependencies. These
functions will mainly be used to automate some visual tests or to improve the
documentation of other packages.
## Installation
You can install the CRAN version with:
``` r
install.packages("locatexec")
```
## Related work
* Packages pagedown is providing `find_chrome()` for finding "Google Chrome".
* Packages findpython is providing `find_python_cmd()` for finding "python".
* If you want to go deeper with 'R' and 'node.js', I recommend
package [packer](https://packer.john-coene.com/).
* If you want to go deeper with 'R' and 'Python', I recommend
package [reticulate](https://rstudio.github.io/reticulate/).