Learn R Programming

berryFunctions (version 1.22.5)

funSource: Source code of a function

Description

open source code of a function in a loaded or specified package on github.com/cran or github.com/wch/r-source

Usage

funSource(x, character.only = is.character(x), local = FALSE)

Value

links that are also opened with browseURL

Arguments

x

Function name, with or without quotation marks. Trailing brackets are removed: xx() -> "xx".
Can be package::function, which must be quoted for non-loaded packages.

character.only

If TRUE, look for SomeFun instead of MyFun in case MyFun <- "SomeFun". DEFAULT: is.character(x)

local

Open offline version of the code? Lacks comments and original formatting of source code. DEFAULT: FALSE

Author

Berry Boessenkool, berry-b@gmx.de, Jan+Dec 2016, May 2017, April 2019

See Also

https://github.com/brry/rskey#rskey to add this as a keyboard shortcut

Examples

Run this code
if (FALSE)  ## browser windows should not be opened in CRAN checks
funSource("head")
funSource(message()) # handles brackets if fun can be evaluated without input
funSource("require", local=TRUE) # usefull when offline

funSource("OSMscale::earthDist") # works even for non-installed CRAN packages

is.error(funSource("earthDist"), TRUE, TRUE) # Error for unloaded package
require(plotrix); require(scales)
funSource(rescale) # from the last loaded package

tail <- function(...) stop("This is a dummy function. Type: rm(tail)")
funSource("tail")
rm(tail)


Run the code above in your browser using DataLab