Put the following lines in a file - call it dmean. The source function reads in the file and executes the lines within in the same way as if they had been typed at the keyboard. After running you will see that it has created x1,x2,m1,m2 and dm .
Source files are a useful way of storing specific strings of analysis functions.
If you find you have a process that you use a lot, perhaps one that calls several S-plus functions, you can write your own function to do it. That can be made into a new Splus function. This is your new function object. The curly bracket then starts the code for the function. This is a comment.