Beispiel #1
0
func test() {

	eval("1+3*4")

	R.EvalOrDie("library(stats)")

	x := R.NewNumericVector([]float64{11.0, 2.0, 31.0, 14.0, 51.0, 16.0, 7.0, 28.0})
	fmt.Println("x: ", x.ToArray())
	p := R.Protect(x.ToSexp())
	defer p.Unprotect()

	R.SetSymbol("x", x)
	eval("sum(x)")

}
Beispiel #2
0
func eval(expression string) *R.Result {
	r := R.EvalOrDie(expression)
	fmt.Println(expression, "=", r.AsNumeric().Get(0))
	return r
}