Next: Entering Data
Up: Splus/R
Previous: I Need Help!
  Contents
Perhaps the most important operator in S-plus and/or R is appropriately named ``the assignment operator'' and is written using one of the following: the underscore character, less than character followed by a hyphen, or a hyphen followed by a greater than character. The following commands illustrate the usage of this operator. The first two lines will assign a vector to the variable named `x' using the c() function.
> x_c(1,2,3,4,5) # anything after # is a comment!!
> x <- c(1,2,3,4,5) # same as above, except using <-
Next, we use the -> command in order to assign the contents of x into another vector named y. The previous two assignments are more standard and likely what you will find in documentation guides online, however the -> is available.
> x -> y
To see the what the variables contain, simply type their name at the R or S prompt.
> x
[1] 1 2 3 4 5
> y
[1] 1 2 3 4 5
Computer Support Group
2002-10-07