An open API service indexing awesome lists of open source software.

https://github.com/ardata-fr/locatexec


https://github.com/ardata-fr/locatexec

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(locatexec)
```

# locatexec

[![R build status](https://github.com/ardata-fr/locatexec/workflows/R-CMD-check/badge.svg)](https://github.com/ardata-fr/locatexec/actions)

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/).