Simple Utility Providing Terminal Access to all R Functions

A small utility which wraps Rscript and provides access to all R functions from the shell.


Build Status cran license downloads

attempt to make a fun cli for R

A small utility which wraps Rscript and provides easy access to all R functions from the terminal.


This aims to provide an easy command-line interface to all R functions.

Usage: funr [-h -v] <name of a function> <arguments to the function [<options>=<value>]>

funr -h            Show this help
funr -h <function> Show help for a specific function
funr -v            Show extra verbose messages for debugging this package
funr <func>        Find and run <function>
funr <func> [args] Run <func> with supplied [arguments]
funr <pkg::func>   Load the package <pkg>, and then run <func>

Using a base package

## load help for rnorm
funr -h rnorm
    Normal                  package:stats                  R Documentation
    The Normal Distribution
       Density, distribution function, quantile function and random

## sample 10 numbers from a normal distribution
funr rnorm n=10
    -1.244571 1.378112 0.02189023 -0.3723951 0.282709 -0.22854 -0.8476185 0.3222024 0.08937781 -0.4985827

Using a non-base package Loading a package automatically by ::

## load help file for knitr
funr -h knitr::knit
    knit                   package:knitr                   R Documentation
    Knit a document
       This function takes an input file, extracts the R code in it
       according to a list of patterns, evaluates the code and writes the
       output in another file. It can also tangle R source code from the

Knit a HTML file using a example R markdown input from knitr package:

## get path to an example Rmd file. Assuming we have knitr installed.
## Save the filename in a BASH variable rmd
## Pipes are supported starting version 0.1.2
funr system.file package=knitr fl=examples/knitr-minimal.Rmd | funr knitr::knit2html input=-
    loading pkg: knitr
    processing file: ... knitr/examples/knitr-minimal.Rmd
    output file:

Adding funr to your scripts

Create a file (called norm.r), which looks like the following:

#!/usr/bin/env Rscript

# define your functions
norm_hist <- function(n){
  x = rnorm(n)

out = funr(commandArgs(trailingOnly = TRUE))

Make sure you have the shebang like with #!/usr/bin/env Rscript, so that shell knows that this is a Rscript. Also, add execution privilige to the script using:

chmod ugo+rx norm.r

Now, one may call the function:

norm.r norm_hist n=100

## OR
Rscript norm.r norm_hist n=100

Using devtools from terminal

Its it quite easy to customize the help text and load some default packages.

## download custom funr script
wget -O ~/bin/devtools

## installing a repo from github
devtools install_github repo="sahilseth/flowr"

## cd into a pacakge you want to check and run
devtools check .

## cd into a pacakge you want to build and run
devtools build .


  • Fetch all named parameters of the function and supply shell arguments after converting to the correct type
  • load help files, providing easy access to R man pages.
  • Automatically load any package and use any of its exported functions


This package is under active-development, you may watch for changes using the watch link above.


automatically placed in your bin, and updated when the package gets updated

## a stable version

## OR a latest developmental version

## setup
    A small script funr has been copied to ~/bin.
    Consider adding ~/bin to your PATH variable, by running this:
    echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
    After opening a new shell session, running funr from the shell should work

To be able to run this utility without the need to use the full path, you need to add the folder containing the funr script to your PATH variable. The setup function copies a shortcut to this script to the ~/bin folder. Then you would need to add ~/bin to your PATH variable. You may do this using this command:

echo 'export PATH=$PATH:~/bin' >> ~/.bashrc

Alternatively, you may copy a shortcut to the funr script to any of the following folders on a linux/mac machine.

## Usually Unix based systems already contain these folders in the PATH variable:

## Assuming /usr/local/bin is already in the path variable (check using echo $PATH),
## this might be a good place to install funr. 
## This would make it accesible to ALL users of the machine/server

## get path to the funr script
Rscript -e 'system.file("scripts/funr", package="funr")' ## get the path from this command:

## create a shortcut to the scruot
ln -s /Library/Frameworks/R.framework/Versions/3.2/Resources/library/funr/scripts/funr /usr/local/bin/


funr 0.3.0

  • NEW: A new function, to detect the path, where R script resides. This is similar to $0 in bash scripting. This functionality is missing in R
  • better error messages in case of failures

funr 0.2.0

  • NEW: added beta support to unix pipes
  • some bug fixes in render_funr

funr 0.1.0

  • funr() outputs a class of funr, which is essentially a list.
  • This ensures that when print is called, it prints it pretty
  • Appreciate if function returns as invisble, do not display the results.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.3.2 by Sahil Seth, 6 years ago

Report a bug at

Browse source code at

Authors: Sahil Seth [aut, cre]

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports utils

Suggests testthat

Suggested by flowr.

See at CRAN