Next: screen() Up: MacAnova Help File Previous: save()   Contents


Create a scalar variable: x <- 3.1415927; c <- "Hi, I'm Frank"; no <- F

Keywords: variables, syntax
A scalar variable is a vector of length 1.  It can be REAL, LOGICAL or
CHARACTER.  It consists of one item of information.

For practically all purposes, a matrix or array all of whose dimensions
are 1 (matrix(sqrt(2), 1), for example) is also considered to be a
scalar variable.

You can create scalar variables in many ways.  Here are some examples.

  Cmd> sqrt2 <- sqrt(2); twopi <- 2*PI # REAL

  Cmd> bananas <- 7; cost <- prices[bananas]*3.1 # REAL

  Cmd> filename <- "babydata.txt"; today <- weekdays[5] # CHARACTER

  Cmd> fitmean <- F; expensive <- prices[bananas] > .49 # LOGICAL

In the third example, "babydata.txt" is an example of what is often
called a quoted string - character information enclosed between two
double quotation marks.

See topics 'file_names' for the use of CHARACTER scalars as file names.

See topics 'variables', 'arithmetic' and 'transformations' for more
information about the use of scalar variables.

Gary Oehlert 2003-01-15