Interact with github rscripts Project

Share:

Description

The github rscripts project at https://github.com/harrelfe/rscripts contains R scripts that are primarily analysis templates for teaching with RStudio. This function allows the user to print an organized list of available scripts, to download a script and load it into an RStudio script editor window, to list scripts whose major category contains a given string (ignoring case), or to list all major and mino categories.

Usage

1
2
3
4
getRs(file=NULL, guser='harrelfe', grepo='rscripts', gdir='raw/master',
      dir=NULL, where='https://github.com/harrelfe/rscripts/raw/master',
      browse=c('local', 'browser'), cats=FALSE,
      put=c('rstudio', 'source'))

Arguments

file

a character string containing a script file name. Omit file to obtain a list of available scripts with major and minor categories.

guser

GitHub user name, default is 'harrelfe'

grepo

Github repository name, default is 'rscripts'

gdir

Github directory under which to find retrievable files

dir

directory under grepo in which to find files

where

base URL in Github for raw rendering of code text

browse

When showing the rscripts contents directory, the default is to list in tabular form in the console. Specify browse='browser' to open the online contents in a web browser.

cats

Leave at the default (FALSE) to list whole contents or download a script. Specify cats=TRUE to list major and minor categories available. Specify a character string to list all scripts whose major category contains the string (ignoring case).

put

Leave at the default ('rstudio') to load file into the RStudio script editor window. Use put='source' to source() the file. This is useful when the file just defines a function you want to use in the session.

Value

a data frame or list, depending on arguments

Author(s)

Frank Harrell and Cole Beck

See Also

download.file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
getRs()             # list available scripts
scripts <- getRs()  # likewise, but store in an object that can easily
                    # be viewed on demand in RStudio
getRs('introda.r')  # download introda.r and put in script editor
getRs(cats=TRUE)    # list available major and minor categories
categories <- getRs(cats=TRUE)
# likewise but store results in a list for later viewing
getRs(cats='reg')   # list all scripts in a major category containing 'reg'
getRs('importREDCap.r', put='source')   # source() to define a function
# source() a new version of the Hmisc package's cut2 function:
getRs('cut2.s', grepo='Hmisc', dir='R', put='source')

## End(Not run)

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