FATE simulationR/POST_FATE.graphic_evolutionStability.R
    POST_FATE.graphic_evolutionStability.RdThis script is designed to produce one graphical representation
for a FATE simulation : the evolution through time of the total
abundance and evenness of each habitat.
POST_FATE.graphic_evolutionStability(
  name.simulation,
  file.simulParam = NULL,
  movingWindow_size = 3,
  movingWindow_step = 1,
  opt.doPlot = TRUE
)a string corresponding to the main directory
or simulation name of the FATE simulation
default NULL. 
 A string
corresponding to the name of a parameter file that will be contained into
the PARAM_SIMUL folder of the FATE simulation
default 3. 
 An integer
corresponding to the size (in years) of the moving window that will
be used to calculate metrics of habitat stability
default 1. 
 An integer
corresponding to the step (in years) between the years of the moving
window
(optional) default TRUE. 
 If TRUE,
plot(s) will be processed, otherwise only the calculation and reorganization
of outputs will occur, be saved and returned
A list containing two data.frame objects with the
following columns, and one ggplot2 object :
HABconcerned habitat
yearconcerned simulation year
totalAbundancetotal abundance over all the pixels within the concerned habitat
no.PFGnumber of PFG over all the pixels within the concerned habitat
evennessevenness over all the pixels within the concerned habitat
HABconcerned habitat
no.yearsnumber of simulation years used (moving window size)
yearStepstep between each simulation year of the moving window
yearStartfirst simulation year of the moving window
yearEndlast simulation year of the moving window
metricconcerned metric (either totalAbundance or
      evenness)
meanmean value of the concerned metric over the years of the concerned moving window
sdvalue of standard deviation of the concerned metric over the years of the concerned moving window
cvvalue of coefficient of variation of the concerned metric over the years of the concerned moving window
ggplot2 object, representing the evolution of
  total abundance and evenness of each habitat 
Two POST_FATE_TABLE_HAB_evolution_[...].csv files are created :
stability1always, containing tab.hab
stability2if successive years available, containing
  tab.stab
One POST_FATE_[...].pdf files is created :
GRAPHIC_A 
 stabilityto visualize for each habitat the evolution of its total abundance and its evenness through simulation time
This function allows to obtain, for a specific FATE simulation and
a specific parameter file within this simulation, one preanalytical graphic :
the evolution of total abundance (FATE
  arbitrary unit) and evenness (between 0 and
  1) of each habitat through simulation time, with evenness
  representing the uniformity of the species composition of the habitat
  (similar to Shannon entropy) :
  $$
  \text{evenness} = - \frac{\Sigma(\text{proportion}_{\text{ PFG}_i} *
  log(\text{proportion}_{\text{ PFG}_i}))}{log(\text{no.PFG})}
  $$
  with $$
  \text{proportion}_{\text{ PFG}_i} = \frac{abund_{\text{ PFG}_i
  \text{, }\text{Habitat}_j}}{abund_{\text{ PFG}_{all}\text{, }
  \text{Habitat}_j}}
  $$
If the information has been provided (see
POST_FATE.temporalEvolution), the graphics will be also done
per habitat. 
It requires that the POST_FATE.temporalEvolution
function has been run and that the file
POST_FATE_TABLE_PIXEL_evolution_abundance.csv exists.