# Getting Started with MSMGOptimizer

    library(MSMGOptimizer)

## Overview

The MSMGOptimizer package provides a ‘Shiny’ (web application framework for R) application for converting ‘Excel’-based Life Cycle Inventory (LCI) data into ‘SimaPro’ CSV (Comma-Separated Values) format for use in Life Cycle Assessment (LCA) modeling.

Developed by the Mine Sustainability Modeling Group (MSMG) at Missouri University of Science and Technology under NSF (National Science Foundation) Award No. 2219086.

## Installation

    # Install from CRAN
    install.packages("MSMGOptimizer")

    # Or install the development version from GitHub
    remotes::install_github("Duah-Philip/MSMGOptimizer")

## Bundled Example Files

The package ships with example ‘Excel’ setup files and a tutorial document in its `inst/extdata` directory. These serve as templates for structuring your own Life Cycle Inventory (LCI) data.

    # List all bundled example files
    list.files(system.file("extdata", package = "MSMGOptimizer"))
    #> [1] "Multiproduct_Setup_File.xlsx"   "Setup_File.xlsx"
    #> [3] "Sheet_by_Sheet_Setup_File.xlsx" "Tutorial.docx"

You can retrieve the path to any individual file using `msmg_example()`:

    # Get the full path to the standard setup file
    msmg_example("Setup_File.xlsx")
    #> [1] "C:/Users/DPBXC/AppData/Local/Temp/Rtmpwjp3qF/Rinst6de8353e6591/MSMGOptimizer/extdata/Setup_File.xlsx"

    # Confirm the tutorial document is present
    file.exists(msmg_example("Tutorial.docx"))
    #> [1] TRUE

## Verifying the Installation

    # Confirm the Shiny app directory is correctly installed
    app_path <- system.file("shiny", package = "MSMGOptimizer")
    file.exists(app_path)
    #> [1] TRUE

## Launching the Application

The main function `ShinyMSMGOptimizer()` launches the interactive ‘Shiny’ application. It is intended for use in an interactive R session only and cannot be run in automated scripts or during `R CMD check`.

    # Launch the optimizer (interactive session only)
    if (interactive()) {
      ShinyMSMGOptimizer()
    }

Once launched, the application allows you to:

- Upload an `.xlsx` or `.xls` file containing your LCI data
- Preview each worksheet before conversion
- Convert all sheets to individual ‘SimaPro’ CSV files
- Download the results as a single ZIP archive

## Excel File Format

Your ‘Excel’ file must follow the MSMG (Mine Sustainability Modeling Group) layout. Each worksheet represents one LCI process. Use the bundled setup files as templates — see `msmg_example()` for access.

Column A should contain the exchange type code for each row:

Code | ‘SimaPro’ Section
--- | ---
(blank) | Materials / Fuels
`Raw` | Resources
`Air` | Emissions to Air
`Water` | Emissions to Water
`Soil` | Emissions to Soil
`Waste` | Final Waste Flows
`Social` | Social Issues
`Economic` | Economic Issues
`Wastetotreatment` | Waste to Treatment

## Further Help

For questions or bug reports, please open an issue on GitHub: https://github.com/Duah-Philip/MSMGOptimizer/issues