Coder Social home page Coder Social logo

r-internals's Introduction

R internals

This repo aims to provide some useful additional information about R's internal C API, or Rapi for short. This site draws heavily from Section 5 ("System and foreign language interfaces") of Writing R extensions, R internals, and inspection of R's source code to see how functions are used.

Here we focus on best practices and modern tools. To wit, we recommend that you use R_NO_REMAP so all API functions have the prefix R_ or Rf_:

#define R_NO_REMAP
#include <R.h>
#include <Rinternals.h>

(Including <Rinternals.h> seems like bad form. However, it doesn't actually give you access to the "internal" internal API unless you set some additional flags. Instead it lets you access the "public" internal API, which is both necessary and safe. Yes, this is confusing.)

SEXPs

At the C-level, all R objects are stored in a common datatype, the SEXP, or S-expression. A SEXP is a variant type, with subtypes or SEXPTYPEs for all R's data structures. This site roughly breaks Rapi into chapters based on the SEXPTYPE the functions work with:

  • Vectors cover the most important data structures: vectors. This includes LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, VECSXP, RAWSXP, and EXPRSXP.

  • Strings: Character vectors are a more complex object made of vector CHARSXPs.

  • Environments, or ENVSXPs.

  • Functions, including CLOSXPs and the rarer BUILTINSXPs, SPECIALSXPs and FUNSXPs.

  • Symbols, SYMSXPs.

  • Pairlists, including LISTSXPs and the related NILSXP, LANGSXP, and DOTSXP. This chapter also includes a discussion of attributes, which are powered by pair lists.

  • External pointers, or XPTRSXPs.

Other categories are:

r-internals's People

Contributors

hadley avatar kevinushey avatar jimhester avatar renkun-ken avatar ironholds avatar stewid avatar

Watchers

James Cloos avatar Hoard McCookie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.