Documentation ¶
Overview ¶
Package sexp provides an API for interacting with R SEXP values. Except where noted, values are allocated by the R runtime.
Here be dragons ¶
The API provided by the sexp package only minimally interacts with the R runtime, so deviations from behavior expected by the R runtime are possible. This package should be used with caution and client packages should ensure correct behavior with adequate testing from the R side.
Building the sexp package requires having CGO_LDFLAGS_ALLOW="-Wl,-Bsymbolic-functions" and installations of R and pkg-config.
Index ¶
- func ComplexNA() complex128
- func IntegerNA() int32
- func IsComplexNA(c complex128) bool
- func IsIntegerNA(i int32) bool
- func IsLogicalNA(b int32) bool
- func IsRealNA(f float64) bool
- func LogicalNA() int32
- func RealNA() float64
- type Builtin
- type Character
- type Closure
- type Complex
- type Dot
- type Environment
- type Expression
- type Info
- func (i Info) Debug() bool
- func (i Info) Extra() uint16
- func (i Info) GCClass() int
- func (i Info) GCGen() int
- func (i Info) GP() uint16
- func (i Info) IsAltRep() bool
- func (i Info) IsInUse() bool
- func (i Info) IsObject() bool
- func (i Info) IsScalar() bool
- func (i Info) Named() uint16
- func (i Info) Space() bool
- func (i Info) String() string
- func (i Info) Trace() bool
- func (i Info) Type() Type
- type Integer
- type Lang
- type List
- type Logical
- type Promise
- type Raw
- type Real
- type Special
- type String
- type Symbol
- type Type
- type Value
- func (v *Value) Attributes() *List
- func (v *Value) Export() unsafe.Pointer
- func (v *Value) Info() Info
- func (v *Value) IsNull() bool
- func (v *Value) Names() *String
- func (v *Value) Pointer() unsafe.Pointer
- func (v *Value) SetAttribute(name []byte, attr *Value)
- func (v *Value) SetNames(names *String)
- func (v *Value) Value() *Value
- func (v *Value) Valuer() Valuer
- type Valuer
- type Vector
- type WeakReference
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComplexNA ¶
func ComplexNA() complex128
ComplexNA returns the R complex NA value. The value returned is NA+0i.
func IsComplexNA ¶
func IsComplexNA(c complex128) bool
IsComplexNA returns whether c is an NA value. This is true if either of the parts of c is NA.
Types ¶
type Builtin ¶
type Builtin struct {
// contains filtered or unexported fields
}
Builtin is an R language built-in function.
type Character ¶
type Character struct {
// contains filtered or unexported fields
}
Character is the R representation of a string.
func NewCharacter ¶
NewCharacter returns a scalar string corresponding to s.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func NewCharacterFromBytes ¶
NewCharacterFromBytes returns a scalar string corresponding to b.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*Character) String ¶
String returns a Go string corresponding the the R characters. The returned string is allocated by the Go runtime.
type Closure ¶
type Closure struct {
// contains filtered or unexported fields
}
Closure is an R closure.
func (*Closure) Environment ¶
Environment returns the environment in which to evaluate the function.
type Complex ¶
type Complex struct {
// contains filtered or unexported fields
}
Complex is an R complex vector.
func NewComplex ¶
NewComplex returns a complex vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*Complex) Unprotect ¶
func (v *Complex) Unprotect()
Unprotect unprotects the SEXP. It is equivalent to UNPROTECT(1).
func (*Complex) Vector ¶
func (v *Complex) Vector() []complex128
Vector returns a slice corresponding to the R vector.
type Dot ¶
type Dot struct {
// contains filtered or unexported fields
}
Dot is an R pairlist of promises.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is a current execution environment.
func (*Environment) Enclosing ¶
func (v *Environment) Enclosing() *Value
Enclosing returns the enclosing environment.
func (*Environment) HashTable ¶
func (v *Environment) HashTable() *Value
HashTable returns the environment's hash table.
func (*Environment) Value ¶
func (v *Environment) Value() *Value
Value returns the generic state of the SEXP value.
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression is an R expression.
func (*Expression) Len ¶
func (v *Expression) Len() int
Len returns the number of elements in the vector.
func (*Expression) Value ¶
func (v *Expression) Value() *Value
Value returns the generic state of the SEXP value.
func (*Expression) Vector ¶
func (v *Expression) Vector() []*Value
Vector returns a slice corresponding to the R expression.
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
Integer is an R integer vector.
func NewInteger ¶
NewInteger returns an integer vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*Integer) Unprotect ¶
func (v *Integer) Unprotect()
Unprotect unprotects the SEXP. It is equivalent to UNPROTECT(1).
type Lang ¶
type Lang struct {
// contains filtered or unexported fields
}
Lang is an R language object.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is an R linked list.
type Logical ¶
type Logical struct {
// contains filtered or unexported fields
}
Logical is an R logical vector.
func NewLogical ¶
NewLogical returns a logical vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*Logical) Unprotect ¶
func (v *Logical) Unprotect()
Unprotect unprotects the SEXP. It is equivalent to UNPROTECT(1).
type Promise ¶
type Promise struct {
// contains filtered or unexported fields
}
Promise is an R promise.
func (*Promise) Environment ¶
Environment returns the environment in which to evaluate the expression.
func (*Promise) Expression ¶
Expression returns the expression to be evaluated.
func (*Promise) PromiseValue ¶
PromiseValue returns the value of the promise.
type Raw ¶
type Raw struct {
// contains filtered or unexported fields
}
Raw is an R raw vector.
func NewRaw ¶
NewRaw returns a raw vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
type Real ¶
type Real struct {
// contains filtered or unexported fields
}
Real is an R real vector.
func NewReal ¶
NewReal returns a real vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*Real) Unprotect ¶
func (v *Real) Unprotect()
Unprotect unprotects the SEXP. It is equivalent to UNPROTECT(1).
type Special ¶
type Special struct {
// contains filtered or unexported fields
}
Special is an R language built-in function.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is an R character vector.
func NewString ¶
NewString returns a character vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*String) Unprotect ¶
func (v *String) Unprotect()
Unprotect unprotects the SEXP. It is equivalent to UNPROTECT(1).
type Symbol ¶
type Symbol struct {
// contains filtered or unexported fields
}
Symbol is an R name value.
func (*Symbol) String ¶
String returns a Go string of the symbol name. The returned string is allocated by the Go runtime.
func (*Symbol) SymbolValue ¶
Value returns the value of the symbol.
type Type ¶
type Type byte
Type is the SEXPTYPE enum defined in Rinternals.h.
const ( NILSXP Type = 0x0 SYMSXP Type = 0x1 LISTSXP Type = 0x2 CLOSXP Type = 0x3 ENVSXP Type = 0x4 PROMSXP Type = 0x5 LANGSXP Type = 0x6 SPECIALSXP Type = 0x7 BUILTINSXP Type = 0x8 CHARSXP Type = 0x9 LGLSXP Type = 0xa INTSXP Type = 0xd REALSXP Type = 0xe CPLXSXP Type = 0xf STRSXP Type = 0x10 DOTSXP Type = 0x11 ANYSXP Type = 0x12 VECSXP Type = 0x13 EXPRSXP Type = 0x14 BCODESXP Type = 0x15 EXTPTRSXP Type = 0x16 WEAKREFSXP Type = 0x17 RAWSXP Type = 0x18 S4SXP Type = 0x19 NEWSXP Type = 0x1e FREESXP Type = 0x1f FUNSXP Type = 0x63 )
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is an SEXP value.
var ( // NilValue is the R_NilValue as a *Value type. It must not be altered. NilValue *Value = asValue(C.R_NilValue) // UnboundValue is the R_UnboundValue as a *Value type. It must not be altered. UnboundValue *Value = asValue(C.R_UnboundValue) )
func (*Value) Attributes ¶
Attributes returns the attributes of the SEXP value.
func (*Value) Export ¶
Export returns an unsafe pointer to the SEXP value first converting a nil value to the R NilValue.
func (*Value) SetAttribute ¶
SetAttribute sets the given attribute of the SEXP value to attr.
type Valuer ¶
type Valuer interface {
Value() *Value
}
Valuer is the general data type interchange interface. All SEXP types satisfy the Valuer interface.
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector is a generic R vector.
func NewVector ¶
NewVector returns a generic vector with length n.
The allocation is made by the R runtime. The returned value may need to call its Protect method.
func (*Vector) Unprotect ¶
func (v *Vector) Unprotect()
Unprotect unprotects the SEXP. It is equivalent to UNPROTECT(1).
type WeakReference ¶
type WeakReference struct {
// contains filtered or unexported fields
}
WeakReference is an R weak reference.
func (*WeakReference) Len ¶
func (v *WeakReference) Len() int
Len returns the number of elements in the vector.
func (*WeakReference) Value ¶
func (v *WeakReference) Value() *Value
Value returns the generic state of the SEXP value.
func (*WeakReference) Vector ¶
func (v *WeakReference) Vector() []*Value
Vector returns the four elements of an R weak reference.
Notes ¶
Bugs ¶
Currently the API does not provide the capacity to create all SEXP types.