Skip to content

R package: RNativeAPI - Documentation and Examples of the R Native API (Proof of Concept)

Notifications You must be signed in to change notification settings

HenrikBengtsson/RNativeAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R package: RNativeAPI - Documentation and Examples of the R Native API

A proof-of-concept package documenting the R Native API via the built-in R help system. The help pages are written in Roxygen2 that are compiled to Rd format and then rendered by R as regular help pages.

Disclaimer: This is just a proof of concept; I'm not claiming this is the best approach.

Examples

Help pages

HTML version

Screenshot of help(getAttrib)

Text version

> options(help_type = "text")
> ?RNativeAPI::getAttrib

getAttrib              package:RNativeAPI              R Documentation

Gets and Sets an Attribute of an R Object

Description:

     Gets and Sets an Attribute of an R Object

Usage:

     getAttrib(vec, name)
     
     setAttrib(vec, name, val)
     
Arguments:

     vec: (SEXP) An R object.

    name: (SEXP) A character of length one.

     val: (SEXP) An R object.

Value:

     getAttrib() returns (SEXP) the value of attributename.

     setAttrib() returns (SEXP) a copy of R objectvecwith attributenameset.

C API:

     SEXP getAttrib(SEXP vec, SEXP name)
     SEXP setAttrib(SEXP vec, SEXP name, SEXP val)

R API:

     value <- attr(vec, name)
     attr(vec, name) <- val

Source:

     Declaration: src/include/Rinternals.h

     Implementation: src/main/attrib.c

Displaying functions

> RNativeAPI::getAttrib
function (vec, name) 
{
    vec = SEXP
    name = SEXP
    return(SEXP)
}
<bytecode: 0x561c1cd594c0>
<environment: namespace:RNativeAPI>

Comment: By a customized class and print() method, the above can probably be presented much nice. With some efforts, it could even display the actual source code (there are already R packages providing functionalities for this).

About

R package: RNativeAPI - Documentation and Examples of the R Native API (Proof of Concept)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages