Learn R Programming

Introduction

The primary purpose of the UKFE R package is to implement the regional flood frequency methods outlined by the Flood Estimation Handbook (FEH; available at https://www.ceh.ac.uk/data/software-models/flood-estimation-handbook) and associated updates. However, there are numerous other functions of use to the hydrologist.

The UKFE package was initially developed by Anthony Hammond in 2020, and he has been updating it regularly since then with additional functionality and in response to new published methods and changes to best practice.

In 2025, the Environment Agency commissioned JBA Consulting to undertake testing of the package, to write this documentation and training material and to assess future needs. Changes to the package for v1.0.0 were a result of this testing and funded by the Environment Agency. The training material is available at https://agqhammond.github.io/ukfe-training-materials/.

Contents

The 'Changelog' tab summarises updates in each version of the UKFE.

Under 'Articles', there are quick guides to the following topics:

  • Basic R concepts and resources (R quick start guide).

  • Data inputs.

  • Data visualisation.

  • FEH statistical analysis.

  • ReFH analysis.

  • Troubleshooting common errors.

There is also a 'References' article, which contains the references of books, user guides or papers cited throughout the documentation.

There is no assumption that readers of these guides are experienced 'R' users, but there is an assumption of familiarity with the application of the FEH methods. More detailed step-by-step guidance can be found in the training material. There is an introduction to some R concepts that may be useful in the 'R quick start guide' article.

Note that some of the information in the vignettes is based on that of the FloodHydroStats website (https://www.floodhydrostats.com/ukfe-package-feh-quick-guide).

Hints and tips

For more information about the functions discussed in the guides and further functions of the package, all the functions are detailed in the 'References' tab (with links to their help files) and in a PDF via the following link: https://cran.r-project.org/package=UKFE/UKFE.pdf

Details can also be viewed in the package documentation within the 'R' environment. To get help with individual functions, you can type help(FunctionName) or ?FunctionName. If using RStudio, you can click on the 'Packages' tab in the bottom right pane (assuming the default layout), search for UKFE, and then click on it. You will then see a list of functions; each can be clicked for more details. To get a list of the function names, type ls("package:UKFE").

Note that for any functions that take file paths, on Windows operating systems, the backslashes will need to be changed to forward slashes, or the file path will need to be stated as follows: r"{my\file\path}".

Many of the examples throughout this documentation have the outputs from running the code displayed below the code.

Installation guide

It is recommended that the UKFE R package be used in RStudio (an integrated development environment for R). You will first need to install R from https://cran.r-project.org/ and then RStudio can be downloaded from https://posit.co/download/rstudio-desktop/.

Once RStudio is open, the package must be installed and then loaded to access its functions.

Note that installing the package only needs to be done once (although it will need redoing if the UKFE package is updated or if you update your version of R). Once you have installed the package, it will be saved in your package library.

The package must be loaded from the library at the start of each new R session to make its functions available.

The following commands can be entered into the console to carry out these steps.

Install from CRAN

Install the UKFE package: install.packages("UKFE")

Install from GitHub

First, install the remotes package if you do not already have it installed: install.packages("remotes")

Then, install UKFE directly from GitHub: remotes::install_github("agqhammond/UKFE")

You may be prompted to update package dependencies — choosing option "1: All" is recommended.

Load the package

Once installed, load it into your R session: library(UKFE)

You can also check the installed version with: packageVersion("UKFE")

Data

Acknowledgement: Data from the UK National River Flow Archive.

This package is based on data from the National River Flow Archive (NRFA). There is a pre-processing script that converts new releases of the NRFA Peak Flow Dataset into data frames suitable for use within UKFE.

Note that the unit tests include a small subset of data from the NRFA Peak Flow Dataset, consisting of XML and AM files. This data sample can only be used for test purposes. Please see the NRFA website (https://nrfa.ceh.ac.uk/) for station metadata, the download of the full peak flows dataset (https://nrfa.ceh.ac.uk/data/peak-flow-dataset), and the data licence (https://eidc.ceh.ac.uk/licences/nrfa-data-terms-and-conditions-for-api-access-to-time-series-data-and-metadata/).

Feedback

If you have any feedback or suggestions, then please contact Anthony Hammond at floodhydrostats@gmail.com or contribute to the GitHub discussion page (https://github.com/agqhammond/UKFE/issues). You can submit edits and additions to the package through GitHub.

Copy Link

Version

Install

install.packages('UKFE')

Monthly Downloads

240

Version

1.0.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Anthony Hammond

Last Published

October 10th, 2025

Functions in UKFE (1.0.2)

DDF99

FEH99 depth duration frequency precipitation model
DDF99Pars

DDF99 parameters from .xml files
ConvertGridRef

Convert between British National Grid Reference (BNG) and Latitude and Longitude or Irish Grid references.
DeTrend

Linearly detrend a sample
DDFImport

DDF13 or DDF22 results from .xml files
DDF

DDF results from a DDFImport object
GEVAM

Generalised extreme value distribution - estimates directly from sample
FlowSplit

Flow splitter
EVPlot

Extreme value plot (frequency and growth curves)
ERPlot

Extreme rank plot
GenLogPars

Generalised logistic distribution parameter estimates
GenParetoEst

Generalised Pareto distribution estimates from parameters
GEVEst

Generalised extreme value distribution estimates from parameters
GenParetoPars

Generalised Pareto distribution parameter estimates
GEVGF

Generalised extreme value distribution growth factors
GetAM

Get an annual maximum sample from the National River Flow Archive sites suitable for pooling
GetDataMetOffice

Get regional Met Office average temperature or rainfall series (monthly, seasonal, and annual).
GetDataEA_Rain

Get Environment Agency rainfall data (England).
GetDataEA_QH

Get flow or level data from the Environment Agency's Hydrology Data Explorer
GetCDs

Get catchment descriptors from the National River Flow Archive sites considered suitable for median annual maximum flow estimation (QMED) and pooling.
GumbelEst

Gumbel distribution estimates from parameters
GumbelAM

Gumbel distribution - estimates directly from sample
GEVPars

Generalised extreme value distribution parameter estimates
GenLogAM

Generalised logistic distribution - estimates directly from sample
GumbelGF

Gumbel distribution growth factors
GumbelPars

Gumbel distribution parameter estimates
EncProb

Encounter probabilities
FlowDurationCurve

Flow duration curve
DiagPlots

Diagnostic plots for pooling groups
DonAdj

Donor adjustment candidates & results
GoFComparePool

Goodness of fit comparison (for a pooling group)
EVPlotAdd

Add lines and/or points to an extreme value plot
GenLogGF

Generalised logistic distribution growth factors
GoFCompare

Goodness of fit comparison (single sample)
GenLogEst

Generalised logistic distribution estimates from parameters
EVPool

Extreme value plot for pooling groups
GenParetoGF

Generalised Pareto distribution growth factors
LRatioChange

Adjust L-Ratios in a pooling group
Kappa3Est

Kappa3 distribution estimates from parameters
GetDataNRFA

Get National River Flow Archive data using gauge ID.
GenParetoPOT

Generalised Pareto distribution - estimates directly from sample
GetDataSEPA_QH

Get flow or level data from the Scottish Environmental Protection Agency.
Kappa3AM

Kappa3 distribution - estimates directly from sample
QMEDData

National River Flow Archive descriptors and calculated statistics for sites suitable for QMED & pooling
QMED

QMED (median annual maximum flow) estimate from catchment descriptors
LSkew

Linear Skewness (LSkew)
Pool

Create pooling group
POTt

Peaks over threshold (POT) data extraction (quick)
GetQMED

QMED from a gauged site suitable for QMED
GetDataSEPA_Rain

Get Scottish Environment Protection Agency (SEPA) hourly rainfall data.
NGRDist

British national grid reference (NGR) distances
QMEDfseSS

QMED factorial standard error for gauged sites
LcvUrb

Urban adjustment for the linear coefficient of variation (Lcv)
MonthlyStats

Monthly Statistics
QMEDPOT

Empirical estimate of QMED from peaks over threshold (POT) data
QMEDLink

QMED Linking equation
QMEDDonEq

QMED donor adjustment
UEF

Urban expansion factor
ThamesPQ

Kingston upon Thames daily flow and catchment precipitation 2000-10-01 to 2015-09-30
SimData

Data simulator
TrendTest

Trend hypothesis test
UAF

Urban adjustment factor (UAF) and percentage runoff urban adjustment factor (PRUAF)
UKOutline

UK outline
Kappa3GF

Kappa3 distribution growth factors
Lcv

Linear coefficient of variation (Lcv)
LSkewUrb

Urban adjustment for the linear skewness (LSkew)
WungLcv

Ungauged pool weighted linear coefficient of variation (Lcv)
WeightsGLSkew

Site gauged linear skewness (LSkew) weightings
WGaugLcv

Gauged pool weighted linear coefficient of variation (Lcv)
Zdists

Zdist Goodness of fit measure for pooling groups
Kappa3Pars

Kappa3 distribution parameter estimates
OptimPars

Optimise distribution parameters
LKurt

Linear Kurtosis (LKurt)
H2

Heterogeneity measure (H2) for pooling groups.
HydroPlot

Hydrological plot of concurrent discharge and precipitation
NRFAData

National River Flow Archive descriptors and calculated statistics for sites suitable for pooling
LMoments

Lmoments & Lmoment ratios
NonFloodAdjPool

Non-flood adjustment for pooling groups
POTextract

Peaks over threshold (POT) data extraction
WeightsUnLcv

Site ungauged linear coefficient of variation (Lcv) weightings
NonFloodAdj

Non-flood adjustment
PoolSmall

Create pooling group for small catchments
PoolEst

Pooled flood estimates
QuickResults

Quick pooled results
Rating

Stage-Discharge equation optimisation
WeightsGLcv

Site gauged linear coefficient of variation (Lcv) weightings
ReFH

Revitalised Flood Hydrograph Model (ReFH)
SCF

Seasonal correction factor (SCF)
WeightsUnLSkew

Site ungauged linear skewness (LSkew) weightings
WungLSkew

Ungauged pool weighted linear skewness (LSkew)
Uncertainty

Uncertainty quantification for gauged and ungauged pooled estimates
WGaugLSkew

Gauged pool weighted linear skewness (LSkew)
AMImport

Import an annual maximum (AMAX) sample from NRFA peak flow .AM files
ARF

Areal reduction factor (ARF)
AddGauge

Add an AMAX sample
BFI

Baseflow index (BFI)
AMplot

Plot of the annual maximum sample
AnnualStat

Annual statistics extraction
AggDayHour

Aggregate a time series
Bootstrap

Bootstrap
AMSP

National River Flow Archive (NRFA) annual maximum data for sites suitable for pooling
CDsXML

Import catchment descriptors from .xml files
DDFExtract

Derive and plot rainfall Depth Duration Frequency curves.
DesHydro

Design hydrograph extraction