In this talk, attendees will get an introduction to writing command-line interfaces in R. The talk begins with a discussion of fundamental command-line topics like managing output streams, exit codes, and environment variables. After that, the talk will explain each argument to the "Rscript" executable. The talk will then describe how to write your own R programs that take in command-line arguments, using builtin functions like
commandArgs()
and external packages like{argparse}
and{crayon}
. The talk concludes with a demo of two R command-line interfaces used in the{lightgbm}
project: one for running linting with{lintr}
in continuous integration and one for building a C++ library using CMake. Sample code will be available on GitHub prior to and following the talk.
See DEMO.md
for the examples used in the talk.
- (virtual) LA R Users, March 2021 (slides | video)