nchern bae9c3fe85 Updated readme | 10 年之前 | |
---|---|---|
R | 10 年之前 | |
c | 11 年之前 | |
example | 10 年之前 | |
.gitignore | 11 年之前 | |
README.md | 10 年之前 |
Go(golang) bindings for R language
This is simple binding to eval R expressions and pass results to/from Go code.
WARNING!
Project in the early stage, memory leaks and even SIGFAULTs are possible. Use it on your own risk.
R.Init()
exactly in main goroutine of the app(i.e. not in goroutine created by your app). This was found by experiments. Possible reason is clashing between process thread stack and goroutine stack. As a result, its impossible to run R-related code in tests as go test run its testing function in custom goroutine per test.#cgo CFLAGS:
directive in sources.libR.so
is avaliable. Set $LD_LIBRARY_PATH
if R istallation is not system-wide.$R_HOME
is set and pointed to your R location before you run any R-related code.go run main.go
under go-R/example directory.package main
import (
"fmt"
"github.com/nchern/go-R/R"
)
func main() {
R.Init()
x := R.NewNumericVector([]float64{1, 2, 3})
R.SetSymbol("x", x)
r := R.EvalOrDie("sum(x)").AsNumeric()
fmt.Println(r.Get(0))
}
More examples are in test code.