Script Header: Ensure pacman is Installed

Description

Generate a string for the standard pacman script header that, when added to scripts, will ensure pacman is installed before attempting to use it. pacman will attempt to copy this string (standard script header) to the clipboard for easy cut and paste.

Usage

1
p_boot(load = TRUE, copy2clip = interactive())

Arguments

load

logical. If TRUE ; library(pacman) is added to the end of the script header.

copy2clip

logical. If TRUE attempts to copy the output to the clipboard.

Details

The script header takes the form of:

if (!require("pacman")) install.packages("pacman"); library(pacman)

This can be copied to the top of scripts to make it easy to run scripts if the user shares them with others or to aid in long term script management. This may also be useful for blog posts and R help sites like TalkStats or StackOverflow. In this way functions like p_load can be used without fear that others don't have pacman installed.

Value

Returns a script header string (optionally copies to the clipboard).

Examples

1

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.