To install it, add
(autoload 'S "/home/CHIMAERA/hseltman/.EmacsS.el" "Starts inferior Splus" t) (autoload 'S-mode "/home/CHIMAERA/hseltman/.EmacsS.el" "Mode for editing S source" t)to your .emacs file in your root directory. Even better, copy the two files to your space, and refer to it there. Once it is installed, when you are in emacs, use Alt-x S<Enter> to start the Splus mode of emacs, and enter the starting directory. Then you can split the screen (Ctrl-x 2) and edit files in one window while running Splus in another.
From the Splus window's prompt line ("> "), you can use the editing codes listed above to edit your line. Use Alt-P and Alt-N to bring up previous lines for editing. Use Alt-R to search for previous lines to edit.
One big advantage of Splus mode is that you can get automatic completion of file names and variable names, e.g. read.table("My<Tab> will expand to e.g. read.table("MyFile.S, and ks<Alt-/(a slash)> will expand to ks.gof.
In S-mode use the form help(nlmin,win=T) for help (or if help.start() is running, just use ?nlmin).
On the menus, try Help/Describe Mode for more information. The following (edited) section is especially useful:
Sending code to the S-process Other commands are also available for evaluating portions of code in the S process. These commands cause the selected code to be evaluated directly by the S process as if you had typed them in at the command line; the `source()' function is not used. Note: these commands work only if the file containing the code has a .q or .S file name suffix. The commands for evaluating code are: * `C-c C-j' (`S-eval-line') Send the line containing point to the S process. * `C-c M-j' (`S-eval-line-and-go') As above, but returns you to the S process buffer as well. * `C-c C-f' or `ESC C-x' (`S-eval-function') Send the S function containing point to the S process. * `C-c M-f' (`S-eval-function-and-go') As above, but returns you to the S process buffer as well. * `C-c C-r' (`S-eval-region') Send the text between point and mark to the S process. * `C-c M-r' (`S-eval-region-and-go') As above, but returns you to the S process buffer as well. * `C-c C-b' (`S-eval-buffer') Send the contents of the edit buffer to the S process. * `C-c M-b' (`S-eval-buffer-and-go') As above, but returns you to the S process buffer as well. * `C-c C-n' (`S-eval-line-and-next-line') Sends the current line to the S process, echoing it in the process buffer, and moves point to the next line. Useful when debugging for stepping through your code. It should be stressed once again that these `S-eval-' commands should only be used for evaluating small portions of code for debugging purposes, or for generating transcripts from source files. When editing S functions, `C-c C-l' is the command to use to update the function's value. One final command is provided for spot-evaluations of S code: `C-c C-e' (`S-execute-in-tb') Prompt for an S expression and evaluate it. Displays result in a temporary buffer. This is useful for quick calculations, etc. All the above commands are useful for evaluating small amounts of code and observing the results in the process buffer. A useful way to work is to divide the frame into two windows; one containing the source code and the other containing the process buffer.Full documentation and source code for S-mode (Emacs Speaks S)
Frm3to5_sum(v>=3 & <=5)
# My subset has 17 colors: dark black, red, orange, # green, blue, purple, brown # and light grey, red, orange, # green, blue, purple, brown plus white. nice.colors_ps.colors.rgb[c(41,194,457,156,133,340,217,444, 45,196,453,157,370,337,207,433,1),]You use the colors by adding col=n, where n is 1 to 17 for nice.colors, to any plot command.
If you want to use X11() to test your plot on screen first,
use X11("-xrm 'splus*colors: white black red
2 green 2 blue gray red 2 green 2 blue white'") (this is in
my f.X11C() function; see "Setup" below). Once the graph looks
OK on the screen, to print it in color, you must first make a
postscript file: type
dev.copy(device=postscript,file="MyFile.ps",colors=nice.colors),
and then dev.off(). An alternative to using
,colors=nice.colors) in each dev.copy() call is to use
ps.options(colors=nice.colors) once per S-plus session.
To use color in motif(), run motif(), then select "Color Scheme..."
from the "Options" menu. Click on a scheme, e.g. "Cyan to Red", then
click "Apply". (If you get an error message, quit Netscape
or other color hogging programs and try again.) Note the order of
the colors for "lines", "text" (including plot symbols), etc. Use
e.g. ,col=3 in a plotting command to plot in the third color
on the list. Or, change some of the colors on the list (be sure to
click "Apply" again). To make color postscript files, just use the
same dev.copy trick shown above. To directly print color plots,
use ps.options.send(colors=xgetrgb(), background=xgetrgb("background"))
before using the motif print button.
For simpler debugging problems, try adding browser() at various points through your program. Then you can evaluate any expressions when the program stops at the browser() lines. Just type the name of a variable or type an expression, and it will be evaluated. You can even type expressions because you are really interested in their side effects, e.g. plot(x,y) or write.table(x) or x=3*y. Type "c" to continue through your function or "stop" to immediately cancel the function.
motif() # on Linux, only motif plots implement double buffering x=seq(1.0,100.0,1.0); y=rnorm(100) double.buffer("back") # plots are drawn invisibly "in the back" for (f in seq(0.8, 0.1, -0.05)) { plot(x,y,main=paste("f =",f)); lines(lowess(x,y,f=f)) double.buffer("copy") # move the "in the back" plot "to the front" sleep(1) # increase the argument for a slower movie } double.buffer("front") # return plotting to normal
> jnk_cut(runif(50,0,30),6) > levels(jnk) [1] " 0.2554031+ thru 5.071073" " 5.0710725+ thru 9.886742" [3] " 9.8867419+ thru 14.702411" "14.7024114+ thru 19.518081" [5] "19.5180808+ thru 24.333750" "24.3337502+ thru 29.149420" > levels(jnk)_midpt(jnk,2) > levels(jnk) [1] "2.66" "7.48" "12.29" "17.11" "21.93" "26.74"
For color plots on screen (as opposed to directly to a postscript file) X11 is used. A new color device can be opened to compare multiple maps if you use ,new=T. If you want to send the map to the screen and later use dev.copy(postscript,file="myfile.ps");dev.off() to get a postscript version, you should use ,setpscol=T to set the postscript colors to match the screen colors. To make a denser (and slower) rendering of the colors use e.g. density=250.
For speed, only the states passed to colormap() have outlines. To add outlines for all states, use ,outline=T. If only a few are missing, it is quicker to use, e.g., ,outline=c("New Jersey","Oklahoma").
For Splus version 5.x, it appears I can't set the colors through my program. You must set them as follows: type motif(). In the graph window choose options, color scheme, create new scheme. Call the scheme, e.g. WYRB10, and set the background to white and the colors for all the other lines to black white c yellow c red c black, where "c" is the "spread" which is 10 by default. Choose apply to make this the current color scheme. Now colormap() will map correctly. Regardless of how you set the motif() colors, the outfile= form of colormap() will produce an appropriately colored postscript file.
Here is a postscript reference paper on maps in Splus.
On Splus 2000, first source SurvEDA.ssc, then source cbSurvEDA.ssc, then source guiSurvEDA.ssc. This will create a "MyStats" menu item that you can use to run SurvEDA. Among other features, the last plot parameters will be memorized and appear as the defaults when you re-run the command, you can specify the maximum number of subjects per plot, you can specify colors visually, and multiple plots appear as "pages" that you can flip between.
All links active 5/25/2006. Please report missing links to