Learn R Programming

seacarb

Carbonate chemistry with R

In 2003, Jean-Pierre Gattuso and Aurélien Proye put together seacarb, an R package that calculates various parameters of the carbonate system in seawater. The package was subsequently upgraded. In 2008, a new version (2.0) was built with the assistance of Héloïse Lavigne. Five additional functions were included to assist in the design of perturbation experiments to investigate ocean acidification and other functions were revised in order to strictly follow the "Guide to best practices for ocean CO2 measurements" (Dickson et al., 2007). Seacarb uses equations mostly from the following sources:

  • Dickson A. G., Sabine C. L. & Christian J. R., 2007. Guide to best practices for ocean CO2 measurements. PICES Special Publication 3:1-191.
  • DOE, 1994. Handbook of methods for the analysis of the various parameters of the carbon dioxide system in sea water; version 2. Dickson, A. G. and Goyet, C., editors. ORNL/CDIAC-74, 1994.
  • Frankignoulle M., 1994. A complete set of buffer factors for acid/base CO2 system in seawater. Journal of Marine Systems 5: 111-118.
  • Orr J. C., Epitalon J.-M., Dickson A. G. & Gattuso J.-P., 2018. Routine uncertainty propagation for the marine carbon dioxide system. Marine Chemistry 207:84-107.
  • Zeebe R. E. & Wolf-Gladrow D. A., 2001. CO2 in seawater: equilibrium, kinetics, isotopes. Amsterdam: Elsevier, 346 pp.

Portions of the code were adapted, with permission from the authors, from the Matlab files mentioned above. I am grateful to Richard Zeebe and Dieter Wolf-Gladrow for that. Héloïse Lavigne contributed much to seacarb in 2008 and 2009; this was critical to the launch of version 2.0 and subsequent updates. Portions of code and corrections have also been contributed by Jean-Marie Epitalon (2004, 2018), Bernard Gentili (2006), Karline Soetaert (2007) and Jim Orr (2007, 2010, 2018, 2023). Jean-Marie Epitalon considerably improved the code, leading to much faster calculations in version 3.0.

Orr et al. (2015) assessed seacarb together with other packages which calculate the seawater carbonate chemistry. In 2018, options were added to propagate uncertainties (Orr et al., 2018).

This program is provided free under the GNU General Public License (GNU GPL). It will be improved using the comments that I will receive. If you are new to R, please check the manuals and FAQs available on the R-project web site to get information on how to install R and the seacarb package on your system. Please only report and comment on seacarb, not on general problems related to R.

Briefly, after installing R and if you have an Internet connection, here is the simplest way to install seacarb:

  • Launch R
  • To install seacarb (to be done only once), type the following command: install.packages("seacarb")
  • To load the seacarb package into memory in order to use it (to be done each time R is launched), type the following command: library(seacarb)

The seacarb package can be downloaded from the Comprehensive R Archive Network (CRAN; see link below). The documentation is included in the package and is accessible using standard R commands. Please give due credit to the publications mentioned above and cite seacarb as follows:

Orr J., Gattuso J.-P., Epitalon J.-M. & Lavigne H., 2026. seacarb: seawater carbonate chemistry. R package version 3.4.0. https://CRAN.R-project.org/package=seacarb

Copy Link

Version

Install

install.packages('seacarb')

Monthly Downloads

1,343

Version

3.4.2

License

GPL (>= 2)

Maintainer

James Orr

Last Published

November 6th, 2026

Functions in seacarb (3.4.2)

Kn

Dissociation constant of ammonium (mol/kg)
Ksi

Dissociation constant of Si(OH)4
Pcoeffs

Coefficients used for pressure-correcting the equilibrium constants
Om

Carbonate saturation state for magnesian calcites
Ks

Stability constant of hydrogen sulfate (mol/kg)
Kspa

Solubility product of aragonite (mol/kg)
Kspc

Solubility product of calcite (mol/kg)
Pcorrect

Pressure correction of equilibrium constants
Kw

Ion product of water (mol2/kg2)
sir

Parameters of the seawater carbonate system including the substrate-inhibitor-ratio (SIR)
buffesm

Buffer capacities of the seawater carbonate system from Egleston et al. (2010), corrected and enhanced
amp

pH value of the AMP buffer
bjerrum

Bjerrum plot
bor

Total boron concentration (mol/kg)
alkalinity

Example data file for function at
sir_b

Parameters of the seawater carbonate system with boron addition, including the substrate-inhibitor-ratio (SIR)
buffderiv

Analytic partial derivatives of the Bolin sensitivity Be
sir_full

Parameters of the seawater carbonate system including the substrate-inhibitor-ratio (SIR) - extension of carb
buffergen

Buffer factors of the seawater carbonate system as defined by Hagens and Middelburg (2016)
buffer

Buffer parameters of the seawater carbonate system
carb

Parameters of the seawater carbonate system
eos2teos_geo

Convert temperature and salinity from EOS-80 to TEOS-10
derivnum

Numerical derivatives of seawater carbonate system variables
carbfull

Parameters of the seawater carbonate system - extension of carb
eos2teos_chem

Convert temperature and salinity from EOS-80 to TEOS-10
kfg

variable for internal use
carbb

Parameters of the seawater carbonate system with boron addition
errors

Uncertainty propagation for computed marine carbonate system variables
f2pCO2

Converts the CO2 fugacity to CO2 partial pressure
p2d

Converts pressure in dbar to depth in meters
fCO2insi

fCO2 at in situ temperature
p2fCO2

Converts pCO2 (partial pressure in CO2) into fCO2 (fugacity of CO2)
buffzwg

Bolin sensitivity and Revelle factor of the seawater carbonate system from Zeebe and Wolf-Gladrow (2001), corrected and enhanced
buffsun

Bolin sensitivity and Revelle factor via the condensed common-template equation of Sundquist et al. (1979)
d2p

Converts depth in meters to pressure in dbar
fH

Total activity coefficient for H+
oa

Perturbation of the seawater carbonate system
pCO2insi

pCO2 at in situ temperature
p2xCO2

Converts partial pressure of CO2 to mole fraction of CO2
pHconv

Conversion of pH
seacarb_test_P300

Test data file (at P=300) to test the use of the carb function
pHinsi

pH at in situ temperature and pressure
sa2sp_chem

From absolute to practical salinity
sa2sp_geo

From absolute to practical salinity
pTA

pTA
sp2sa_chem

From Practical to absolute salinity
pmix

pmix
pgas

pgas
ppH

ppH
sf_calc

Calculation of calibrated pH for seaFET sensor
theta

Potential temperature of seawater
tris

pH of TRIS buffer
sf_calib

Calibration coefficients for seaFET sensor
teos2eos_geo

Convert temperature and salinity from TEOS-10 to EOS-80
teos2eos_chem

Convert temperature and salinity from TEOS-10 to EOS-80
pHslope

Slope of the calibration curve of a pH electrode
pHnbs2sws

Converts pH from NBS to SWS scale
rho

Density of seawater (kg/m3)
pHsws2nbs

Converts pH from SWS to NBS scale
psi

Molar ratio of CO2 released vs CaCO3 precipitated
pHspec

Calculates pHT from results of spectrophotometric measurements
x2pCO2

Converts mole fraction to partial pressure of CO2
vapress

Computes vapor pressure of seawater
kconv

Conversion factors to change the pH scale of dissociation constants
pCa

pCa
seaFET

Test seaFET data file
pH

Potentiometric pH
sp2sa_geo

From practical to absolute salinity
seacarb_test_P0

Test data file (at P=0) to test the use of the carb function
speciation

ionic forms as a function of pH
K0

Henry's constant mol/(kg/atm)
K1p

First dissociation constant of phosphoric acid (mol/kg)
K2p

Second dissociation constant of phosphoric acid (mol/kg)
K3p

Third dissociation constant of phosphoric acid (mol/kg)
K2

Second dissociation constant of carbonic acid (mol/kg)
K1

First dissociation constant of carbonic acid (mol/kg)
Kb

Dissociation constant of boric acid (mol/kg)
Kf

Equilibrium constant of hydrogen fluoride (mol/kg)
K2si

Second dissociation constant of Si(OH)4
Khs

Dissociation constant of hydrogen sulfide (mol/kg)