gh: gh functions

ghR Documentation

gh functions

Description

The function gh carries out the following operation on a file named x. It searches for a match for x within the active repository, utilizing fuzzy string matching. If no unique match is identified, an error is thrown along with suggestions for potential "best" matches. Otherwise, the following operation are performed:

  • gh(x, 'open') or ghopen(x): Opens a file in the local browser if the file extension is html or pdf, otherwise in the RStudio editor.

  • gh(x, 'load') or ghload(x): Loads the contents of a file with import.

  • gh(x, 'source') or ghsource(x): Executes the contents of a file with source.

  • gh(x, 'app') or ghapp(x): Tries to open the file with the default application of the OS, see defaultApp().

  • ghdata(x, pkg): Helper function to load data sets from R packages into Python, simulates pkg::x.

Usage

gh(x, what = c("open", "load", "source", "app"), ..., .call = NULL)

ghopen(x, ...)

ghload(x, ...)

ghsource(x, ...)

ghapp(x, ...)

Arguments

x

character(1): name of the file, app or data set

what

character or function: a name of a predefined function or another function. The function must have a formal parameter file.

...

further parameters used in utils::browseURL(), openFile(), rio::import(), or base::source().

.call

the original function call (default: NULL)

Value

invisibly the result of utils::browseURL, openFile(), rio::import(), or base::source().

Examples

if (interactive()) {
  x <- ghopen("bank2.SAV")
  x <- ghload("bank2.SAV")
  str(x)
  x <- ghsource("univariate/example_ecdf.R")
}

mmstat4 documentation built on May 29, 2024, 11:15 a.m.