This is out of date. It seems that almost everyone is using R, not Splus.


To work efficiently with Splus, you need to have a window open in which you can save the commands (those which worked) and the output.
  • Use Emacs Speaks Statistics, ESS, with one window for Splus and another for saved input and output. Start emacs
    > emacs  & 
    Then open a new window (File| Make New Frame or keys Cntrl-X 5b) Now start Splus with commands: Meta-X S. Return when it asks which directory to start from, or you can specify any directory in which you've created a MySwork directory to hold Splus objects. Default is your root directory where it will build the MySwork directory if none exists.

    If the above commands don't work, you need to copy a specially tailored .emacs file to your root directory.

    gauss> cp ~jimrc/.emacs .emacs
    For more details on running within emacs see Emacs Speaks Statistics, ESS. In both cases, I assume you're running an Xsession so that you can mark text by dragging across it with the left mouse button depressed, and paste it by clicking the center mouse button. You can open a graphics window with the (Splus) command:
    > motif()
    > trellis.device()

    After you create a plot, you should be able to print it by clicking on the Graph menu, then the Print choice. If you have any problem, check the Options: Printing choices. You should see `lp' in the command box. If not, change it, click Save and Close, then try Graph: Print again.


    Sample Session

    Startup Splus uses functions for everything, even quit is a function, q(), with no argument in the ()'s. It handles vectors and matrices nicely. It uses <- to assign a value to a variable, but within a function call, = is used to set parameters.


    Help Before you need help get it started with the > help.start() command. This pops up a window which allows you to browse through the commands. I close this down to an icon (LL or small square button in top right of title bar) and use the help command directly. For instance > help(scan) or > ?scan will pop up another window explaining the scan function.


    Example Here are commands to read in the data created previously in emacs and do a regression.
    > tires <- read.table("",col.names=c("hardness","tensile.strength",
    > tires  
    This reads the file and prints out the hardness dataset. It has 3 variables, tires$hardness, tires$tensile.strength, and tires$abrasion.loss. The read.table function brought it in as a data frame. Now to see how it looks, we need to open a graphics window and do a pairs plot.
    > motif()
    > pairs(hardness)
    The motif() command only is done once per session. Other choices for graphics devices are available, eg trellis.device(motif) or postscript("filename") to create a postscript file. The command closes the motif window, or completes the postscript file. Next we'll try fitting a regression model using the lm() (linear models) function. The tilde below means ``is modeled using'', then a ``sum'' of explanatory variables is given.
    > <- lm(abrasion.loss ~ hardness + tensile.strength,
    > summary(
    We'll finish with a plot of residuals versus fitted values, add a reference line at 0. If you want a paper copy of the plot, click the graph menu option above the picture and the print option below that.
    > plot(fitted(,$resid)
    > abline(h=0)
    Exiting After you've looked at the plot, quit q().


    More Help

    Information about unix and emacs.

    Other Stat package demos for unix packages:

    Back to MSU Math Department Home Page


    Author: Jim Robison-Cox
    Last Updated: Tuesday, 14-Jun-2011 16:52:23 MDT