# Revision history [back]

When you start Sage, r is the R interpreter.

Maybe you defined r as something else?

In a new Sage session, the following works:

sage: r
R Interpreter
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
[1] 10.4  5.6  3.1  6.4 21.7


Suppose we define r to some value, then it stops working (of course).

sage: r = 2
sage: r
2
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
Traceback (most recent call last)
...
TypeError: 'sage.rings.integer.Integer' object is not callable


If we reset r, then it works again.

sage: reset('r')
sage: r
R Interpreter
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
[1] 10.4  5.6  3.1  6.4 21.7


When you start Sage, Sage starts, r is predefined as the R interpreter.

Maybe you defined r as something else?(Edit: this does not seem to be the case in CoCalc.)

In a new Sage session, with r predefined as above, the following works:

sage: r
R Interpreter
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
[1] 10.4  5.6  3.1  6.4 21.7


Suppose we define r to some value, then it stops working (of course).

sage: r = 2
sage: r
2
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
Traceback (most recent call last)
...
TypeError: 'sage.rings.integer.Integer' object is not callable


If we reset r, then it works again.

sage: reset('r')
sage: r
R Interpreter
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
[1] 10.4  5.6  3.1  6.4 21.7


In versions of Sage where r is not predefined as the R interpreter, use:

sage: from sage.interfaces.r import r


In a Sage session where r was initially the R interpreter, but was then redefined to be something else, this can also be used, instead of reset('r'), to restore r as the R interpreter.

When Sage starts, r is predefined as the R interpreter.

(Edit: this does not seem to be the case in CoCalc.)

In a new Sage session, with r predefined as above, the following works:

sage: r
R Interpreter
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
[1] 10.4  5.6  3.1  6.4 21.7


Suppose If in such a Sage session we define r to assign some value, other value to r, then it stops working (of course).

sage: r = 2
sage: r
2
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
Traceback (most recent call last)
...
TypeError: 'sage.rings.integer.Integer' object is not callable


If we reset r, then it works again.

sage: reset('r')
sage: r
R Interpreter
sage: x = r([10.4,5.6,3.1,6.4,21.7]); x
[1] 10.4  5.6  3.1  6.4 21.7


In versions of Sage where r is not predefined as To set r to be the R interpreter, whether the Sage being used predefines r that way or not, use:

sage: from sage.interfaces.r import r


In a Sage session where r was initially the R interpreter, but was then redefined to be something else, this can also be used, instead of reset('r'), to restore r as the R interpreter.