• Stars
    star
    206
  • Rank 189,602 (Top 4 %)
  • Language
    R
  • License
    Other
  • Created over 8 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lookup R full function definitions, including compiled code, S3 and S4 methods.

lookup

Lookup R function definitions, including compiled code, S3 and S4 methods from packages installed locally, or from GitHub, CRAN or Bioconductor.

Travis-CI Build Status Coverage Status

luke

Installation

# install.packages("devtools")
devtools::install_github("jimhester/lookup")

See Setup for additional setup instructions.

Example

Normal Functions (with compiled code)

Imgur

S3 generics and methods

Imgur

S4 generics and methods

Imgur

In RStudio IDE

Imgur

Usage

# Lookup a function
lookup::lookup(body)
#> base::body [closure] 
#> function (fun = sys.function(sys.parent())) 
#> {
#>     if (is.character(fun)) 
#>         fun <- get(fun, mode = "function", envir = parent.frame())
#>     .Internal(body(fun))
#> }
#> <bytecode: 0x7fa65cada988>
#> <environment: namespace:base>
#> // c source: src/main/builtin.c#L255-L266
#> SEXP attribute_hidden do_body(SEXP call, SEXP op, SEXP args, SEXP rho)
#> {
#>     checkArity(op, args);
#>     if (TYPEOF(CAR(args)) == CLOSXP)
#>  return duplicate(BODY_EXPR(CAR(args)));
#>     else {
#>  if(!(TYPEOF(CAR(args)) == BUILTINSXP ||
#>       TYPEOF(CAR(args)) == SPECIALSXP))
#>      warningcall(call, _("argument is not a function"));
#>  return R_NilValue;
#>     }
#> }

# Can also open a browser at that function's location
lookup_browse()

Setup

lookup makes heavy use of the GitHub API, which has a rate limit of 60 requests per hour when unauthenticated. You can create a Personal access token with no scope, which will increase your limit to 5000 requests per hour.

The usethis package has a helper function to help you generate such a token, usethis::browse_github_token().

Once you have generated a token, add it to your ~/.Renviron file or shell startup file and it will be automatically used for further requests.

GITHUB_PAT=7d8d0436835d1baXYZ1234

gh::gh("/rate_limit") can be used to query your current usage and limits.

Default printing

lookup can be used as a complete replacement for function printing by attaching the package. To make this the default simply add this to your .Rprofile.

if (interactive()) {
  suppressPackageStartupMessages(library(lookup))
}

If you do not want make this the default simply call lookup::lookup().

How this works

If a base R function is printed that calls compiled code the code is looked up using the R git mirror. If a CRAN package has compiled code it is looked up on the CRAN git mirror. If a package is installed with devtools::install_github() or devtools::install() the remote or local repository location is searched for the code.

This has been tested to work with .Internal, .External, .C, .Call and Rcpp calls.

Issues

This package uses a number of heuristics to find function definitions. This means it can fail in some cases, if you find a function that is not looked up properly, please open an issue.

Thanks

More Repositories

1

knitrBootstrap

A framework to create bootstrap styled HTML reports from knitr Rmarkdown.
HTML
273
star
2

per-directory-history

Per directory history for zsh, as well as global history, and the ability to toggle between them with ^G.
Shell
221
star
3

presentations

Just a place to store and link to presentations I have done
JavaScript
63
star
4

autoinst

Automatically install packages when they are missing
R
54
star
5

fasta_utilities

A collection of scripts developed to interact with fasta, fastq and sam/bam files.
Perl
50
star
6

completeme

WIP
R
38
star
7

rarrow

R bindings to apache arrow
C++
32
star
8

typeCheck

The typeCheck package automatically adds type checking code when types are annotated.
R
26
star
9

dotfiles

Vim Script
23
star
10

lambda

Simple anonymous functions
R
20
star
11

plyrToDplyr

R
20
star
12

regulaR

Regular expressions for humans, a port of Ruby's Regularity library to R (see https://github.com/kevinushey/rex for current development)
R
20
star
13

cran_usage

R
19
star
14

altparsers

C
19
star
15

jimhester.com

HTML
15
star
16

SublimeLinter-contrib-lintr

Python
14
star
17

thank

Give Thanks
R
13
star
18

setup-r

Set up your GitHub Actions workflow with a specific version of R
JavaScript
12
star
19

wercker-r-example

Example of an R project using wercker
12
star
20

r-actions-test

https://jimhester.github.io/r-actions-test/
C
11
star
21

highlite

A Highlighting Library For R
C++
11
star
22

ggplot2ToGgvis

R
11
star
23

bloom

R Bloom filter implementation using Rcpp bindings for dabloom.
C
9
star
24

ida-scripts

collection of scripts for ida pro
Perl
9
star
25

dwarftherapist

Dwarf Therapist is an extension application for the fantastic game Dwarf Fortress. DF is a great game. And it's fun to manage dwarves with keyboard menus until about the 50th one shows up. If you're starting to get overwhelmed you need therapist in your life.
C++
9
star
26

tomatoa

I'd rather be shiny
R
7
star
27

subsetr

Drop-in replacements for `[.data.frame` and `subset.data.frame` with robust non-standard evaluation
R
7
star
28

analysis_framework

A skeleton analysis framework for use with knitr and git.
Perl
6
star
29

note

Play music
R
6
star
30

rtreesitter

R bindings to the Tree-sitter parsing library
Rust
6
star
31

test-glfs

5
star
32

benchthat

Track performance benchmarks for a package over time
R
4
star
33

wercker-step-r-dependencies

Wercker step to install R dependencies
Shell
4
star
34

predpipe

Predict the next pipe function from the previous functions in the chain.
R
3
star
35

stonesense

A retro isometric visualizer for Dwarf Fortress
C++
2
star
36

flickrr

Minimal R API for flickr
R
2
star
37

wercker-step-r-check

Wercker step to check an R package
Shell
2
star
38

dplyrJDBC

JDBC driver for dplyr
R
2
star
39

ex

Example package for using multiple parsers
R
2
star
40

perlrer

Input perl regular expression, get perl results in R!
R
2
star
41

BiocInstaller2

R
1
star
42

copyfile

Investigate a strange bug in copyfile
C
1
star
43

surveillance

mirror of the surveillance package for testing
R
1
star
44

poc-testthat2020

R
1
star
45

wercker-step-r-lint

Wercker step to run R lint
Shell
1
star
46

hashsize

Benchmarks of the R symbol table hashmap
C
1
star
47

BAMSpector

R
1
star
48

TypeTracker

Tracks your typing, and generates typing lessons to improve your typing ability
C++
1
star
49

wercker-step-r-coverage

Wercker step to run R coverage
Shell
1
star
50

aws-check

Shell
1
star
51

Dwarf-Clipboard

Application for Dwarf Fortress to copy parts of a fort and paste them into other locations/forts
C++
1
star