Internal

Internal API

Types

RCall.CharSxpType.

R character string

source
RCall.ClosSxpType.

R function closure

source
RCall.CplxSxpType.

R complex vector

source
RCall.EnvSxpType.

R environment

source
RCall.IntSxpType.

R integer vector

source
RCall.LangSxpType.

R function call

source
RCall.LglSxpType.

R logical vector

source
RCall.ListSxpType.

R pairs (cons) list cell

source
RCall.NilSxpType.

R NULL value

source
RCall.RObjectType.

An RObject is a Julia wrapper for an R object (known as an "S-expression" or "SEXP"). It is stored as a pointer which is protected from the R garbage collector, until the RObject itself is finalized by Julia. The parameter is the type of the S-expression.

When called with a Julia object as an argument, a corresponding R object is constructed.

julia> RObject(1)
RObject{IntSxp}
[1] 1

julia> RObject(1:3)
RObject{IntSxp}
[1] 1 2 3

julia> RObject(1.0:3.0)
RObject{RealSxp}
[1] 1 2 3
source
RCall.RealSxpType.

R real vector

source
RCall.S4SxpType.

R S4 object

source
RCall.StrSxpType.

R vector of character strings

source
RCall.SxpType.

RCall.jl's type Sxp mirrors the R symbolic expression record SEXPREC in R API. These are represented by a pointer Ptr{S<:Sxp} (which is called SEXP in R API).

source
RCall.VecSxpType.

R list (i.e. Array{Any,1})

source
RCall.AnySxpType.

R "any" object

source
RCall.BcodeSxpType.

R byte code

source

R built-in function

source
RCall.DotSxpType.

R dot-dot-dot object

source
RCall.ExprSxpType.

R expression vector

source
RCall.ExtPtrSxpType.

R external pointer

source
RCall.PromSxpType.

R promise

source
RCall.RClassType.

R Class

source
RCall.RawSxpType.

R byte vector

source

R special function

source
RCall.SxpHeadType.

R Sxp header: a pointer to this is used for unknown types.

source
RCall.SymSxpType.

R symbol

source

R weak reference

source

Methods

RCall.anynaMethod.

Check if there are any NA values in the vector.

source
RCall.getattribMethod.

Return a particular attribute of an RObject

source
RCall.getclassMethod.

Returns the class of an R object.

source
RCall.getnamesMethod.

Returns the names of an R vector.

source
RCall.isnaMethod.

Check if the ith member of s coorespond to R's NA values.

source
RCall.isnaMethod.

Check if the members of a vector are NA values. Always return a BitArray.

source
RCall.isnullMethod.

Check if values correspond to R's NULL object.

source
RCall.rcallMethod.

Evaluate a function in the global environment. The first argument corresponds to the function to be called. It can be either a FunctionSxp type, a SymSxp or a Symbol.

source
RCall.rcopyMethod.

rcopy(r) copies the contents of an R object into a corresponding canonical Julia type.

source
RCall.revalFunction.

Evaluate an R symbol or language object (i.e. a function call) in an R try/catch block, returning an RObject.

source
RCall.rimportFunction.

Import an R package as a julia module.

gg = rimport("ggplot2")
source
RCall.rlangMethod.

Create a function call from a function pointer and a list of arguments and return it as an RObject, which can then be evaulated

source
RCall.robjectMethod.

robject(x) converts a Julia object x to a corresponding RObject implictly. Explict conversions could be called with robject(<R Class>, x).

source
RCall.rparseMethod.

Parse a string as an R expression, returning an RObject.

source
RCall.rprintMethod.

Print the value of an Sxp using R's printing mechanism

source
RCall.setattrib!Method.

Set a particular attribute of an RObject

source
RCall.setclass!Method.

Set the class of an R object.

source
RCall.setnames!Method.

Set the names of an R vector.

source
RCall.sexpMethod.

sexp(x) converts a Julia object x to a pointer to a corresponding Sxp Object.

source
RCall.sexpMethod.

Convert a Ptr{UnknownSxp} to an approptiate Ptr{S<:Sxp}.

source
RCall.sexpMethod.

Wrap a Julia object an a R Ptr{ExtPtrSxp}.

We store the pointer and the object in a const Dict to prevent it being removed by the Julia GC.

source
RCall.sexpMethod.

Wrap a callable Julia object f an a R ClosSxpPtr.

Constructs the following R code

function(...) .External(juliaCallback, fExPtr, ...)
source
Base.eltypeMethod.

Element types of R vectors.

source
Base.getindexMethod.

extract the value of symbol s in the environment e

source
Base.getindexMethod.

extract an element from a S4Sxp by label

source
Base.getindexMethod.

extract an element from a PairListSxp by label

source
Base.getindexMethod.

Set element of a VectorSxp by a label.

source
Base.getindexMethod.

extract the i-th element of a PairListSxp

source
Base.isasciiMethod.

Determines the encoding of the CharSxp. This is determined by the 'gp' part of the sxpinfo (this is the middle 16 bits).

  • 0x00000200 (bit 1): set of bytes (no known encoding)
  • 0x00000400 (bit 2): Latin-1
  • 0x00000800 (bit 3): UTF-8
  • 0x00004000 (bit 6): ASCII

We only support ASCII and UTF-8.

source
Base.lengthMethod.

Sxp methods for length return the R length.

Rf_xlength handles Sxps that are not vector-like and R's "long vectors", which have a negative value for the length member.

source
Base.namesMethod.

Returns the names of an R vector, the result is converted to a Julia symbol array.

source
Base.setindex!Method.

assign value v to symbol s in the environment e

source
Base.setindex!Method.

extract an element from a S4Sxp by label

source
Base.setindex!Method.

Set element of a PairListSxp by a label.

source
Base.setindex!Method.

Set element of a VectorSxp by a label.

source
Base.setindex!Method.

assign value v to the i-th element of a PairListSxp

source
Base.sizeMethod.

Returns the size of an R object.

source
RCall.boundMethod.

The R NAMED property, represented by 2 bits in the info field. This can take values 0,1 or 2, corresponding to whether it is bound to 0,1 or 2 or more symbols. See http://cran.r-project.org/doc/manuals/r-patched/R-exts.html#Named-objects-and-copying

source

Called by the R finalizer.

source
RCall.endEmbeddedRMethod.
endEmbeddedR()

Close embedded R session.

source

Event Callback: allows R to process Julia events when R is busy. For example, writing output to stdout while running an expensive R command.

source

find namespace by name of the namespace, it is not error tolerant.

source
RCall.getNamespaceMethod.

get namespace by name of the namespace. It is safer to be used than findNamespace as it checks bound.

source

Get the R parser error msg for the previous parsing result.

source

Called after cell evaluation. Closes graphics device and displays files in notebook.

source

Set options for R plotting with IJulia.

The first argument should be a MIME object: currently supported are

  • MIME("image/png") [default]
  • MIME("image/svg+xml")

The remaining arguments (keyword only) are passed to the appropriate R graphics device: see the relevant R help for details.

source
initEmbeddedR()

This initializes an embedded R session. It should only be called when R is not already running (e.g. if Julia is running inside an R session)

source
RCall.isNAMethod.

Check if a value corresponds to R's sentinel NA values. These function should not be exported.

source

The function called by R .External for Julia callbacks.

It receives a Ptr{ListSxp} containing

  • a pointer to the function itself (Ptr{ExtPtrSxp})
  • a pointer to the Julia function (Ptr{ExtPtrSxp})
  • any arguments (as Ptr{S<:Sxp})
source
RCall.makeExternalPtrFunction.

Create an Ptr{ExtPtrSxp} object

source

Register a function pointer as an R NativeSymbol. We technically are supposed to use RregisterRoutines. Starting from R 3.4, `RMakeExternalPtrFn` is a part of R API in R 3.4. It is probably safe to such to make the external pointer.

source
RCall.naeltypeMethod.

NA element for each R base class

source
newEnvironment([env])

Create a new environment which extends environment env (globalEnv by default).

source
RCall.parseVectorMethod.

A pure julia wrapper of R_ParseVector

source

Prepare code for evaluating the julia expressions. When the code is execulated, the results are stored in the R environment #JL.

source
RCall.preserveMethod.

Prevent garbage collection of an R object. Object can be released via release.

This is slower than protect, as it requires searching an internal list, but more flexible.

source
RCall.protectMethod.

Stack-based protection of garbage collection of R objects. Objects are released via unprotect. Returns the same pointer, allowing inline use.

This is faster than preserve, but more restrictive. Really only useful inside functions.

source
RCall.rcall_pMethod.

Evaluate a function in the global environment. The first argument corresponds to the function to be called. It can be either a FunctionSxp type, a SymSxp or a Symbol.

source

Register finalizer to be called by the R GC.

source
RCall.releaseMethod.

Release object that has been gc protected by preserve.

source
RCall.renderMethod.

Render an inline R script, substituting invalid "$(Expr(:incomplete, "incomplete: invalid string syntax"))

source
RCall.reval_pMethod.

Evaluate an R expression array iteratively. If throw_error is false, the error message and warning will be thrown to stderr.

source
RCall.reval_pMethod.

Evaluate an R symbol or language object (i.e. a function call) in an R try/catch block, returning a Sxp pointer.

source
RCall.rlang_pMethod.

Create a function call from a list of arguments

source
RCall.rparse_pMethod.

Parse a string as an R expression, returning a Sxp pointer.

source

RParseVector wrapped by RtryCatchError. It catches possible R's stop calls which may cause longjmp in c.

source

Set the variable .Last.value to a given value

source

Create an argument list for an R function call, with a varargs "dots" at the end.

source
RCall.sexpnumMethod.

The SEXPTYPE number of a Sxp

Determined from the trailing 5 bits of the first 32-bit word. Is a 0-based index into the info field of a SxpHead.

source
RCall.tryEvalMethod.

A pure julia wrapper of R_tryEval.

source
RCall.unprotectMethod.

Release last n objects gc-protected by protect.

source
RCall.unsafe_arrayMethod.

The same as unsafe_vec, except returns an appropriately sized array.

source
RCall.unsafe_vecMethod.

Represent the contents of a VectorSxp type as a Vector.

This does not copy the contents. If the argument is not named (in R) or otherwise protected from R's garbage collection (e.g. by keeping the containing RObject in scope) the contents of this vector can be modified or could cause a memory error when accessed.

The contents are as stored in R. Missing values (NA's) are represented in R by sentinels. Missing data values in RealSxp and CplxSxp show up as NaN and NaN + NaNim, respectively. Missing data in IntSxp show up as -2147483648, the minimum 32-bit integer value. Internally a LglSxp is represented as Vector{Int32}. The convention is that 0 is false, -2147483648 is NA and all other values represent true.

source
RCall.validate_libRFunction.
validate_libR(libR, raise=true)

Checks that the R library libR can be loaded and is satisfies version requirements.

If raise is set to false, then returns a boolean indicating success rather than throwing exceptions.

source

R API callback to write console output.

source

Macros

RCall.@R_strMacro.
R"..."

An inline R expression, the result of which is evaluated and returned as an RObject.

It supports substitution of Julia variables and expressions via prefix with $ whenever not valid R syntax (i.e. when not immediately following another completed R expression):

R"glm(Sepal.Length ~ Sepal.Width, data=$iris)"

It is also possible to pass Julia expressions:

R"plot(getfield(RCall, Symbol("##49#50"))())"

All such Julia expressions are evaluated once, before the R expression is evaluated.

The expression does not support assigning to Julia variables, so the only way retrieve values from R via the return value.

source
RCall.@rgetMacro.

Copies variables from R to Julia using the same name.

source
RCall.@rimportMacro.

Import an R Package as a Julia module. For example,

@rimport ggplot2

is equivalent to ggplot2 = rimport("ggplot2") with error checking.

You can also use classic Python syntax to make an alias: @rimport *package-name* as *shorthand*

@rimport ggplot2 as gg

which is equivalent to gg = rimport("ggplot2").

source
RCall.@rlibraryMacro.

Load all exported functions/objects of an R package to the current module. Almost equivalent to

__temp__ = rimport("ggplot2")
using .__temp__
source
RCall.@rputMacro.

Copies variables from Julia to R using the same name.

source
RCall.@var_strMacro.

Returns a variable named "str". Useful for passing keyword arguments containing dots.

source

Constants

RCall.globalEnvConstant.

R global Environment.

globalEnv[:x] = 1
globalEnv[:x]
source
RCall.jtypExtPtrsConstant.

Julia types (typically functions) which are wrapped in Ptr{ExtPtrSxp} are stored here to prevent garbage collection by Julia.

source
RCall.typsConstant.

vector of R Sxp types

source