On the surface, MacAnova appears to be quite similar to statistics program S and its successor S-Plus(TM) (which R was patterned on), and this similarity often makes it quite easy to translate S-Plus and R code to MacAnova. But MacAnova differs from S-Plus and R in many important ways. Here are some of the differences, listed here to make it easier for a S-Plus or R user to use MacAnova. The Section numbers refer to the Users' Guide.
MacAnova variable names may contain "_" but not ".".
MacAnova has temporary variables (names starting with @) and allows for the generation of unique variable names in macros using the special suffix $$. S-Plus and R organize things in "frames" so that different functions can use the same names for variables without danger of "collision."
MacAnova has fewer types of variables than does S-Plus and R. There are REAL, CHARACTER and LOGICAL scalars, vectors, matrices and arrays, factors (a special type of REAL vector, see Sec. 3.3), macros (Sec. 2.3, 9.3), GRAPH variables (Sec. 8.5.3), NULL variables, and structures whose components may be any type of variable (Sec. 2.8.16, 9.1). In particular, there is no special time series object and complex data is encoded in REAL variables (Sec. 5.2.3).
MacAnova variables have dimensions and optional coordinate labels (Sec. 2.8.13, 2.8.15, 8.4) but do not have attributes in the S-Plus and R sense. MacAnova variables can have descriptive notes attached.
Missing values are entered as ? (NA is also allowed) and printed as MISSING in MacAnova but entered and printed as NA in S-Plus and R.
In MacAnova 'This is a "quoted" string' is illegal; use "This is a \"quoted\" string" instead. ' is the MacAnova transpose operator.
Line continuation at the prompt is different between MacAnova and S-Plus and R. In MacAnova a line is continued automatically only if a quoted string (Sec. 2.5) lacks a terminating " or a compound command starting with { lacks a terminating }. You can force continuation by ending a line with \. There is a continuation prompt only on non-windowed versions. S-Plus and R continue a line if any bracketted expression starting with ( or [ or { is incomplete.
MacAnova keyword phrases have the form keyword:value instead of keyword=value and you can't abbreviate most keywords.
In MacAnova, a %/% b is equivalent to rsolve(b,a), computing a solution x to the equation x %*% b = a; in S-Plus and R, a %/% b evaluates to floor(a/b).
In MacAnova, vector(1,3,5,2) does what c(1,3,5,2) does in S-Plus and R. If Str is a MacAnova structure all of whose components are the same type, vector(Str) unravels them all and concatenates them into a single vector.
In MacAnova, sum(x), prod(x), max(x), and min(x) operate over the first dimension of x, returning a variable whose first dimension is 1 and the remaining dimensions are the same as those of x. In particular, if x is a matrix, the result is a row vector each of whose elements is derived from one column of x (Sec. 2.12.4). In S-Plus and R, the value of these functions is a scalar summarizing all the values in x.
MacAnova maintains the equivalence of a vector and a column matrix (matrix with 1 column). It never treats a vector as a row vector. Thus, for example, if a is a matrix with 3 rows, vector(1,3,4) %*% a is illegal in MacAnova but c(1,3,4) %*% a is equivalent to t(c(1,3,4)) %*% a in S-Plus and R.
If a is a m by n matrix, in MacAnova a[1,] is a 1 by n matrix (a row vector) and a[,1] is a m by 1 matrix (a column vector). In S-Plus and R both are just plain vectors; in particular, contrary to what you might expect, t(a[1,]) is a 1 by n matrix.
MacAnova has quite different rules for binary operations that combine two variables of different sizes. Suppose m > 1 and n > 1, a is a column vector of length m, b is a 1 by n row vector, c is a m by n matrix, and op is a binary element-wise operator such as *. Then a op c combines a with every column of c, b op c combines b with every row of c, and a op b is a m by n matrix combining every element of a with every element of b. See Sec. 2.10.2. S-Plus and R, when they allow the operation at all, extend a vector cyclically to get a dimension match.
MacAnova does not have the S-Plus and R construct n1:n2. Use run(n1,n2) instead (Sec. 2.8.12 and 2.14).
MacAnova for loops have the form for(index,values){...} (Sec. 9.2.3) instead of for(index in values){...}.
In MacAnova, the statement or statements controlled by if, elseif and else must be a compound command, that is, enclosed in {...} (see Sec. 9.2.1), with { on the same line as if, elseif or else (Sec. 9.2.2). S-Plus and R have neither limitation.
In MacAnova, the statement or statements forming the body of while and for loops must be a compound command, with { on the same line as while or for (Sec. 9.2.3). S-Plus and R have neither limitation.
Although they have some features in common, a MacAnova structure differs from an S-Plus and R list. MacAnova allows structures to be operands of most operators and arguments of transformations and some functions like sum() and max(). To get the same effect in S-Plus and R, you use function lapply(). In MacAnova, if str is a structure, then the value of both str[2] and str[[2]] is component 2 of str and is a structure only if the component itself is a structure. In S-Plus and R, if lis is a list, lis[2] is a list whose only component is component 2 of lis, while lis[[2]] is the component itself. See Sec. 2.8.16 and 9.1.
In MacAnova, you can assign a variable only to an existing structure component. In S-Plus and R, assigning to a non-existing list component, adds a new component to the list.
Linear and generalized linear model analysis is done differently in MacAnova and S-Plus and R. For example, models are specified in different ways. A MacAnova model is a CHARACTER scalar of the form "depvar = term1 + term2 + ...", with typical terms being x1, age or x1.age. A term of the form a.b may express an interaction (when both a and b have previously appeared in the model), a nesting of b within a (when a but not b has previously appeared), or a multidimensional factor (when neither a or b has previously appeared). See Sec. 3.4. In S-Plus and R, a model is specified not by a CHARACTER variable but by a "formula" in which ~ separates the dependent variable from the right hand side of the model, a:b specifies an interaction and b%in%a expresses nesting of b in a. Also MacAnova codes categorical data as "factors" (Sec. 3.3) and S-Plus and R use "category" variables.
MacAnova has very different functions for reading and writing files. When reading unstructured numerical data separated by white space from file data.txt,
x <- vecread("data.txt")
in MacAnova has the same result as
x <- scan("data.txt")
in S-Plus and R; vecread() and scan() differ in more complex situations. MacAnova function matread() reads matrices and arrays retrieving dimension information, but requires that the file be in a special format. It has some similarity with the S-Plus and R function read.table().
If x is a matrix, to obtain roughly the same effect as
write.table(x, file="data.txt")
in S-Plus and R, you can use
matprint("data.txt",x,sep:",",nsig:17,new:T)
in MacAnova.
Graphing is done differently since MacAnova has no concept of graphics device. In its simplest usage, MacAnova function plot() roughly corresponds to S-Plus and R function plot(). Other basic MacAnova plotting commands are lineplot() and chplot(). All recognize keyword phrase add:T, indicating new information is to be added to the previous plot. You can specify that a plot will be low resolution by keyword phrase dumb:T or that it should be written as PostScript to file myplot.ps, say, by keyword phrase file:"myplot.ps". By default, a GRAPH variable LASTPLOT encapsulating the entire graph is produced by all MacAnova plotting commands. See Sec. 2.15 and 8.6.
In addition to the above differences, many MacAnova functions, such as paste(), cat(), diag() and structure(), have the same name as a S-Plus and R function but differ in minor and sometimes major ways.
All MacAnova variables are kept in memory rather than disk. S-Plus variables may correspond to disk files.