# Sample initialization file for MacAnova, updated 001005

# Put it in the same directory or folder as MacAnova itself.

# To activate various macros, variables, other things.
# change 'if(F){' to 'if(T){' and, if necessary, edit any items

# The following change values of various options from their defaults

# Activate the following to ensure that restore(fileName) does not destroy
# your current variables.  Without this you need restore(fileName,delete:F)
if (F){ #keyword 'delete' will have default value F on restore()
	setoptions(restoredel:F)
}

# Those doing frequency analysis of time series might find activating the
# following useful
if (F){ #change default units for angles
	setoptions(angles:"cycles") # or "degrees"
}

if (F){ #change default output for GLM commands
	setoptions(pvals:T,fstats:T)
}

if (F){ #change default output format (edit as desired)
	setoptions(format:"13.6g")
# type help(print) for details on formats
}

if (F){ #change default number of significant digits (edit as desired)
	setoptions(nsig:6)
}

if (F){ #change default font (currently only on Macintosh)
	setoptions(font:"Courier 12")
}

# The following are used by macros getdata and getmacros.  They will
# almost certainly need to be edited to reflect the location of files
# on your hard disk.

# Variables DATAPATH, DATAPATHS, and HOME are set automatically as follows
#  In non-Unix based versions, they are initialized to the name of the
#  directory or folder where MacAnova or MACANOVA.EXE is located
#  In Unix based versions, HOME is set to the user's home directory
#  (environmental variable $HOME) and DATAPATH and DATAPATHS are both
#  set to a value set when MacAnova was compiled.
# Variable DATAFILE is initialized to "macanova.dat"
# Variable MACROFILE is initialized to "macanova.mac"
# Variable MACROFILES is predefined to
# vector("graphics.mac","regress.mac","design.mac","tser.mac","arima.mac",\
#   "mulvar.mac", "math.mac", "macanova.mac")
# These files are searched by getmacros or whenever you attempt to use
# a macro that is not defined.  In some versions, the names may include
# upper case letters, for example, "Arima.mac".

# Activate these to change the above defaults by changing F to T and
# editing what is to the right of '<-'

if (F){ #define Mac style path name for data, macro directory
	DATAPATH   <- "Mac HD:StatData:" ;;#Mac style path name for data, macro folder
;;}

if (F){ #define DOS style path name for data, macro directory
	DATAPATH   <- "C:/MacAnova/" 
	DATAPATHS   <- vector("C:/MacAnova/","D:/Datafiles/", C:/MVMacros/")
;;}

# Note that on DOS/Windows, '/' can be used instead of '\' in specifying paths
# If you prefer '\', it must be doubled in quotes as in "D:\\Datafiles\\"

# Edit and then activate to change name of default data file
if(F){
	DATAFILE  <- "MacAnova.dat" #default data file
;;}

# Edit and then activate to change name of default macro files
if(F){
	MACROFILE <- "macanova.mac" #default macro file
	MACROFILES <- vector("graphics.mac","regress.mac","design.mac",\
		"tser.mac","arima.mac","mulvar.mac", "math.mac", "macanova.mac")
;;}

# If HOME is defined, file name "~/filename" is expanded to
# paste(HOME,filename,sep:SEP) where SEP is '/' or ':' depending on system
# requires version 3.31 or later
if(F){
	HOME <- DATAPATH # will be used to expand filenames of form "~/filename"
;;}

# Activate these if you wish to delete certain pre-defined constants
if(F){
	if(isdefined(DEGPERRAD)){
		delete(DEGPERRAD)
	}
;;}

if(F){
	if(isdefined(PI)){
		delete(PI)
	}
;;}

if(F){
	if(isdefined(E)){
		delete(E)
	}
;;}

# Macros for Unix Lovers
# To activate, change 'F' in next line to 'T'
if(F){
mv        <- macro("@tmp <- $1;delete($1);@tmp",dollars:T) #usage: b <- mv(a)
rm        <- macro("delete($0)") # alias for delete
ls        <- macro("listbrief($0)") # alias for listbrief
ll        <- macro("list($0)") # alias for list
;;}

# Macros for DOS Lovers
# To activate, change 'F' in next line to 'T'
if(F){
rename    <- macro("@tmp <- $1;delete($1);@tmp", dollars:T) #usage: b <- rename(a)
erase     <- macro("delete($0)") # alias for delete
dir       <- macro("list($0)") # alias for list
;;}

# Macro for easy setting print format, e.g., setformat(f,10.4)
# To activate, change 'F' in next line to 'T'
if(F){
setformat <- macro("setoptions(format:\"$2$1\")") #example: setformat(f,10.4)
;;}

# Macro to extract first nlines (default 10) rows of a matrix or array
# To activate change 'F' in next line to 'T'
if(F){
head      <- macro("#head(x) or head(x,nlines)
@y <- argvalue($1,\"argument 1\", \"array\")
@n <- dim(@y)[1]
@k <- if($N > 1){
	argvalue($2,\"number of rows\",\"positive count\")
}else{
	10
}
@J <- run(min(@n,@k))
@y <- @y[@J,,,,,,,,]
delete(@n,@J,@k)
if(isvector(@y)){
	vector(@y)
}else{
	@y
}", dollars:T)
;;}

# Macro to extract last nlines (default 10) rows of a matrix or array
# To activate change 'F' in next line to 'T'
if(F){
tail      <- macro("#tail(x) or tail(x,nlines)
@y <- argvalue($1,\"argument 1\", \"array\")
@n <- dim(@y)[1]
@k <- if($N > 1){
	argvalue($2,\"number of rows\",\"positive count\")
}else{
	10
}
@J <- run(max(@n-@k+1,1),@n)
@y <- @y[@J ,,,,,,,,]
delete(@n,@J,@k)
if(isvector(@y)){
	vector(@y)
}else{
	@y
}", dollars:T)
;;}

# Macro to test identity its arguments; requires version 3.31 or later
# usage:  equal(a, b)
# If a and b are structures, the component names must be identical
# To suppress checking of names, use equal(a,b,F)
# To activate change 'F' in next line to 'T'
if(F){
equal <- macro("# equal(arg1,arg2 [,F]) returns T if arg1 and arg2 identical; otherwise F
@arg1 <- $1
@arg2 <- $2
if (isgraph(@arg1) || isgraph(@arg2)){
	error(\"cannot compare GRAPH variables\")
}
@chknames <- if($N>2){
	$3
}else{
	T
}
@result <- isstruc(@arg1) == isstruc(@arg2)
@result <- if(@result && isstruc(@arg1)){
	ncomps(@arg1) == ncomps(@arg2)
}else{
	@result
}
@result <- if(@result && @chknames && isstruc(@arg1)){
	$S(compnames(@arg1),compnames(@arg2))
}else{
	@result
}
if(@result){
	if(isstruc(@arg1)){
		for(@i,run(ncomps(@arg1))){
			if(!(@result <- $S(@arg1[@i],@arg2[@i],@chknames))){
				break
			}
		}
	}else{
		if (ismacro(@arg1) || ismacro(@arg2)){
			@result <- ismacro(@arg1) && ismacro(@arg2)
			@result <- if(@result){
				paste(@arg1) == paste(@arg2)
			} else {
				F
			}
		} elseif (isnull(@arg1) || isnull(@arg2)){
			@result <- isnull(@arg1) && isnull(@arg2)
		} else{
			@result <- ndims(@arg1)==ndims(@arg2) &&\
				length(@arg1)==length(@arg2)
			@result <- if(@result){
				sum(dim(@arg1)!=dim(@arg2))==0
			}else{
				F
			}
			@result <- if(@result){
				sum(vector(@arg1!=@arg2))==0
			}else{
				F
			}
		}
	}
}
delete(@arg1, @arg2, @chknames)
@result", dollars:T)
;;}
 

