
This repository contains the R scripts used for the data analysis and modelling for the publication:

Manure matters: Prospects for regional banana-livestock integration for sustainable intensification in South-West Uganda, by den Braber et al. in the International Journal for Agricultural Sustainability.

For repeating the analysis and obtaining the figures presented in the paper, do the following:

Start a new R project, and make the following folders:
-data_analysis
-model
-results

Each folder and the content it should contain will be described in detail hereunder.
_______________________________________________________________________________________________________

    Data analysis  
    The folder 'data_analysis' has 2 subfolders:
     -data
     -scripts
     
         
        >sub_folder 'data' containst two sub_sub_folders:
              > 'defintions_protocols' contains a text.file with metadata and a csv file with all
                 the definitions of all the variables used in the input survey  
              > 'raw' contains csv files with all raw (anonymized) data from the input use survey
              
        
        > subfolder 'scripts' contains all the scripts used for the analysis of the input use survey.
        Download the following scripts from the repository and store in this folder:
         1_data_analysis_for_table_3.R
         2_data_analysis_for_table_3.R 
         3_data_analysis_for_table_3.R
         4_figure_4.R
         5_figure_5.R
         6_table_5.R
         my_figure_theme.R
         
         Running the scripts in consecutive order generates the information to fill table 3, and
         generates figures 4,5 and 6 from the paper. These figures and information are 
         automatically stored in folder results. 
         
_______________________________________________________________________________________________________

   Model
    The folder 'model' contains 2 subfolders:
     -data
     -scripts
     
    >sub_folder 'data' contains two sub_sub_folders and several csv files:
              > banana_area_mapping contains the results of a spatial analysis in which the 
                % of banana area was visually estimated for a gridded file. It is used to calculate
                the total banana area in the 2 sub-counties of interest
              > 'sensitivity_analysis' provides the input files for the model sensitivity analysis 
              > the remaining csv files contain otherthe remaingin input files to run the model and 
                to obtain figures 6,7,8,9 and table 4,5 and 6 as presented in the paper.
                
              
        
        > subfolder 'scripts' contains scripts prefix "M". Running these scripts in consecutive 
          order will generate figures 6,7,8,9 and table 4,5 and 6. 
          M1-4 are the subroutines of the model
          M5 contains a wrapper function which activates the sub routines.
          M6 tranforms csv input files into a format which can be read by the model
          M7 transforms the model output in files that can be analyzed furhter
          
          M8 - M16 run the model in several ways to obtain figure 6,7,8,9 and table 4,5 and 6, 
          which are then stored in folder 'results'.
    

          

     
     
