Entering Commands

To have S-PLUS execute a command, enter the command at the prompt and press return. For instance, type 2+3 and then press return.

> 2 + 3
[1] 5
Arithmetic and order of operations work exactly in the ordinary way. Multiplication is *, division is / and exponentiation is ^.

The format for calling a function is functionname(arg1, arg2, ...), or functionname() for a function which takes zero arguments. Typing the function name by itself (with no parentheses) will return the definition of the function. S-PLUS is case-sensitive, so be sure to use the correct capitalization: Functionname() and functionname() are different things.

The square root and absolute value functions need just one argument each:

> sqrt(9)
[1] 3

> abs(-5)
[1] 5
The ``[1]'' which keeps showing up means that the first item on that line is the first item in the vector of output. This indexing is useful when you want to find a particular observation in a long list of output. In the output below, 1000 is the 36th observation.

 [1]    0.73    1.46    2.19    2.92    3.65    4.38    5.11    5.84    6.57
[10]    7.30    8.03    8.76    9.49   10.22   10.95   11.68   12.41   13.14
[19]   13.87   14.60   15.33   16.06   16.79   17.52   18.25   18.98   19.71
[28]   20.44   21.17   21.90   22.63   23.36   24.09   24.82   25.55 1000.00
[37]    1.04    1.30    1.56    1.82    2.08    2.34    2.60    2.86    3.12
[46]    3.38    3.64    3.90    4.16    4.42    4.68    4.94
If you enter an incomplete command (for instance, by forgetting a close-parenthesis), S-PLUS will give you another prompt, this time a ``+''.
> sqrt(16
+
At this point, type the close-parenthesis and the command will execute normally.
> sqrt(16
+ )
[1] 4



Pantelis Vlachos
1/15/1999