![]() |
![]() |
Search DSS Finding Data Analyzing Data Citing data About Us DSS lab consultation schedule (Monday-Friday)
*No appts. necessary during walk-in hrs. Note: the DSS lab is open as long as Firestone is open, no appointments necessary to use the lab computers for your own analysis. ![]() ![]() |
Home
S-Plus SyntaxThe BasicsS-Plus has a very consistent language syntax and many of the basic commands mirror basic unix commands:
Note that all commands in Splus include parentheses (). Sometimes, you'll include things in the parentheses, as you do when you type rm(object). If you're interested in learning a lot more about programming, try typing a function without the parantheses. S-Plus will output the actual function, which may look long and messy.
AssignmentWhen you perform a command in S-Plus it does not automatically become an object. Instead, you must "assign" the output to an object. For example, when you read in data, as we will shortly, you need to tell S-Plus to store this data in a particular object. You do this by assigning it to an objectname. Here's an example:
Try typing this now. Then type givemeafive. You should see a five on your screen. The little arrow (<-) means assign 5 to the object givemeafive. Now, lets see what happens when you forget to assign output to a particular object. Try typing:
Wow, that was a lot of output which you probably did not want to go on the screen. One last thing: <- can be abbreviated as _ (underscore). That makes it easier to type. Now were almost done with the basics.
Types of objectsAs was mentioned earlier, Splus is object oriented. Everything you do in Splus will involve creating objects. This includes both data sets and the linear models you create. Here are three types of objects ypou need to know about:
|