Documentation
¶
Overview ¶
Package roger implements a RServe client, allowing R commands to be evaluted and the resulting data made available to Go applications.
Connect:
rClient, err := roger.NewRClient("127.0.0.1", 6311)
Evaluation:
value, err := rClient.Eval("pi")
fmt.Println(value) // 3.141592653589793
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Packet ¶
type Packet interface {
// GetResultObject will parse the packet's contents, returning a go interface{}.
// If the Packet contains an error this will be returned.
// If conversion fails, an error will be returned.
GetResultObject() (interface{}, error)
// IsError returns a boolean defining whether the Packet contains an error.
IsError() bool
// Returns the packet's error or nil if there is none.
GetError() error
// IsOk returns a boolean defining whether Packet was success
IsOk() bool
}
Packet is the interface satisfied by objects returned from a R command. It contains either the resulting object or an error.
type RClient ¶
type RClient interface {
// Eval evaluates an R command synchronously returning the resulting object and any possible error. Creates a new session per command.
Eval(command string) (interface{}, error)
// Evaluate evaluates an R command asynchronously. The returned channel will resolve to a Packet once the command has completed. Creates a new session per command.
Evaluate(command string) <-chan Packet
// EvaluateSync evaluates an R command synchronously, resulting in a Packet. Creates a new session per command.
EvaluateSync(command string) Packet
// GetSession gets a session object which can be used to perform multiple commands in the same Rserve session.
GetSession() (Session, error)
}
RClient is the main Roger interface allowing interaction with R.
func NewRClient ¶
NewRClient creates a RClient which will run commands on the RServe server located at the provided host and port
type Session ¶
type Session interface {
// Sends a command to RServe which is evaluated synchronously resulting in a Packet.
SendCommand(command string) Packet
// Eval evaluates an R command synchronously returning the resulting object and any possible error. Unlike client.Eval, this does not start a new session.
Eval(cmd string) (interface{}, error)
// Assign value to a variable within the R session.
Assign(symbol string, cont interface{}) error
// Close closes a RServe session. Sessions must be closed after use.
Close()
}
Session is an interface to send commands to an RServe session. Sessions must be closed after use.
Click to show internal directories.
Click to hide internal directories.