This package provides an interface to the FAME time series database from
Sungard. The ti (TimeIndex) and tis (Time Indexed Series) classes in the 
package also provide an alternative to the somewhat inflexible ts class in the
standard R stats package. The tis class maps very closely to the FAME notion
of what a time series is.  

Linux INSTALLATION: 

There is no standard location for a FAME installation, so the configure script
makes no attempt to look for one.  Instead, you must tell R where to find FAME
HLI library and header files.  This can be done in one of two ways:

 (i) The configure script first looks for a FAME environment variable.  If it
     finds one, the HLI directory is assumed to be $FAME/hli.

(ii) Whether there is a FAME environment variable set or not, you can install
     the package with a configure arg  --with-fameHliDir=DIR , i.e., 

R CMD INSTALL --library=library --configure-args='--with-fameHliDir=/opt/fame/fame/hli' fame_1.0.tar.gz

Supplying the HLI location via --configure-args overrides any FAME environment
variable.  

If the configure script does not find the HLI directory for any reason, the
package is built and installed without FAME support.

.Rprofile CONFIGURATION

Your .Rprofile should look something like this:

options(defaultPackages = c(getOption("defaultPackages"), "fame"))
.First.sys()
.First <- function(){
  options(error = quote(recover()), locatorBell = FALSE)
  ps.options(pointsize = 10)
  ## print startup message and finish
  cat(date(), " R started in", pwd(), "by", user(), "with search path\n")
  print(search())
  ## Run command line program if there is one
  if(length(.cmd <- commandLineString()) > 0)
    try(source(textConnection(.cmd), echo = T, prompt.echo = "> "))
}

The ordering of package loading is important. fame (this pkg) has new
implementations of some functions found in the stats and base packages, so it
must appear on the search() list ahead of them.  The standard .First.sys()
proceeds in order through the defaultPackages list, loading each package in
turn to the second position on the search list.  Putting fame last on the
defaultPackages list means it ends up in position 2 in front of the other packages.

.First.sys() loads the default packages.  Normally, the R startup sequence
runs .First.sys() only after it has run .First(), but this is backwards, since it
implies that code in .First() can not make use of the functionality supplied
by packages.  So runs .First.sys() before running .First().

The commandLineString() function is part of this package.  It retrieves
whatever followed --args on the command line, and the .First() function above
proceeds to run it.

Windows INSTALLATION:

The package build without direct FAME support under Windows. The Windows
versions of getfame(), putfame(), fameWhats() and fameWildlist() assume that
you have ssh and socket access to a Linux machine that can run R and FAME.
The Linux R machine must have an .Rprofile set up (as outlined above) to load the
fame package on startup, and to run code supplied on the command when R is
started.  The first time one of the FAME interface functions is called, 
startRemoteServer() fires up an R server session on the Linux machine. The
Windows FAME functions send R code to the server and wait for results coming
back through a socket connection.


CUSTOMIZATION:
There are three functions that you may want to reimplement and put ahead of
fame on the search path.  

  (i) ssh():  The Linux version is very simple and should be fine.  The
      Windows version uses the 'plink' program from the open-source PuTTY ssh
      client.  If you use some other Windows ssh client, you'll have to
      rewrite ssh().

 (ii) fameLocalInit():  When starting FAME, the fameStart() function opens a
      work database and then invokes fameLocalInit().  The supplied
      implementation of fameLocalInit() does nothing.  My own local version
      loads some additional Federal Reserve Board code, i.e., 

      fameLocalInit <- function(){ ## local redefinition
        fameCommand('load file("/opt/fame/frb/pc/lib.pc")', silent = T) 
        fameCommand('load file("/opt/fame/frb/pc/syslib.pc")', silent = T)
      }

(iii) getFamePath():  takes a string argument and returns a path to a
      database. The supplied implementation is pretty trivial:

      getFamePath <- function(dbString){
        ## redefine this function if you have a nice way to find 
        ## the path to a database. return NULL if database corresponding to
        ## dbString could not be found 
        if(file.exists(dbString)) dbString
        else NULL
      }

	  At the Federal Reserve Board, we have "registered" databases, and a
	  shell script that can find the path to a registered database given its
	  name.  So my local implementation of getFamePath() first looks for the
	  direct match with file.exists() as above, but if it doesn't find a
	  match, it also tries the registered databases lookup, returning the path
	  name if it succeeds, and NULL if it doesn't.

Setting Default Frequencies: 

Fame has seven weekly frequencies for weeks ending on Sunday, Monday, and it
has 12 annual frequencies, for years ending on the last day of each of the
12 months. There are also multiple biweekly, bimonthly and semiannual
frequencies.  
At any time you can use the function setDefaultFrequencies() to change which
actual frequencies the strings "weekly", "biweekly", "bimonthly",
"quarterly", "semiannual" and "annual" refer to.   

LAGS:

A number of functions have been reimplemented and/or made generic in this
package.  Only one has really changed its meaning.  The standard R version of
the lag(x, k) function says that a series lagged by a positive k starts
earlier.  The opposite is true for the lag function in this package, to
maintain consistency with the common usage of 'first lag, second lag' and so
on in econometrics.

  
