[R] SPlus script

Rolf Turner rolf.turner at xtra.co.nz
Fri Jun 7 00:22:18 CEST 2013


On 07/06/13 03:19, Scott Raynaud wrote:
> I actually had tried placing arguments in the call but it didn't work.   However, I did
> not think about writing it to a variable and printing.  That seems to have done the
> trick.  Funny, I don't remember having to do that before, but that's not surprising.
>

If I remember correctly --- haven't used Splus for decades --- this is a 
difference
between Splus and R.

In R the output of a function is returned *invisibly* if that function 
is called
from within another function.  And source() is one such other function.

So if you have a script, say "melvin" with the single line:

     sin(42)

and in R you execute

     source("melvin")

you will see no output.  If in another script, say "clyde" you have the
single line

     print(sin(42))

and in R you execute

     source("clyde")

you will see

     [1] -0.9165215

In Splus, IIRC, the print() call is unnecessary.  I.e. you would get the 
same
result by sourcing "melvin" and "clyde".

Current Splus users may correct me if I am wrong about this.

     cheers,

         Rolf Turner



More information about the R-help mailing list