Package 'funr'

Title: Simple Utility Providing Terminal Access to all R Functions
Description: A small utility which wraps Rscript and provides access to all R functions from the shell.
Authors: Sahil Seth [aut, cre]
Maintainer: Sahil Seth <[email protected]>
License: MIT + file LICENSE
Version: 0.3.4
Built: 2025-02-17 04:45:04 UTC
Source: https://github.com/sahilseth/funr

Help Index


funr: providing a simple command-line interface to R functions

Description

Wraps Rscript in a easy to use manner, exposing all R functions from the terminal. The github page provides more details with examples, highlights and caveats.

Usage

funr(args, help_text, script_name = "funr")

Arguments

args

Should always be: commandArgs(trailingOnly = TRUE), when used inside a script. Example

help_text

A simple text to be displayed describing options and usage of this interface. Supplying this, replaces the default text.

script_name

Name of the script. This is used in the the help text. [funr]

Source

https://github.com/sahilseth/funr

Examples

## show funr help
## terminal version: funr -h
funr()


## show rnorm help
## terminal version: funr -h rnorm
render_funr(funr(args=c("-h", "rnorm")))

## Generate a few random numbers
## terminal version: funr rnorm n=10
render_funr(funr(args=c("rnorm", "n=10")))

Enables detection of the folder a script resides in with certain accuracy

Description

R does not have a default way to return and use, the location of a specific script.

Usage

get_script_path()

detect_home()

Source

https://github.com/molgenis/molgenis-pipelines/wiki/How-to-source-another_file.R-from-within-your-R-script


Render output of functions in a print friendly format

Description

If the function returns with invisible, output is suppressed

Usage

render_funr(x, max_rows = 100)

Arguments

x

a output from funr

max_rows

In case output of a function is a data.frame, the number of rows to display.


Setup and initialize some scripts.

Description

Setup and initialize some scripts.

Usage

setup(bin = "~/bin")

Arguments

bin

path to bin folder

Details

Will add more to this to identify cluster and aid in other things


Get path of current script

Description

Get path of current script

Usage

sys.script()

Source

http://stackoverflow.com/questions/1815606/rscript-determine-path-of-the-executing-script

Examples

## Not run: 
## cat foo.R
## library(funr);sys.script()

## source("foo.R")

## Rscript foo.R


## End(Not run)