Setting Up Your rfaR Project
We recommend organizing your analysis as an RStudio project. This keeps file paths relative and reproducible across machines.
Step 1 — Create a new RStudio Project
In RStudio: File → New Project → New Directory → New Project
Name it something like my_dam_rfa/. This creates a
.Rproj file and sets the working directory automatically on
open.
Step 2 — Recommended directory structure
my_dam_rfa/
├── my_dam_rfa.Rproj
├── data/
│ ├── resmodel.csv
│ ├── hydrographs/
│ │ ├── event_1.csv
│ │ └── event_2.csv
│ └── stage_record.csv
├── R/
│ └── my_dam_simulate.R
└── output/
Step 3 — Import your data
rfaR expects data in specific formats. The built-in
datasets show the required structure:
# Reservoir model: elevation, storage, outflow
head(jmd_resmodel)
# Hydrograph: time and flow columns
head(jmd_hydro_apr1999)
# Stage record: date and stage columns
head(jmd_wy1980_stage)Read your own data using read.csv() with relative
paths:
Step 4 — Verify column structure
Before running rfa_simulate(), verify your imported data
matches the expected format: