MyNixOS website logo
Description

Reference on Constants, Units and Uncertainty.

CODATA internationally recommended values of the fundamental physical constants, provided as symbols for direct use within the R language. Optionally, the values with uncertainties and/or units are also provided if the 'errors', 'units' and/or 'quantities' packages are installed. The Committee on Data for Science and Technology (CODATA) is an interdisciplinary committee of the International Council for Science which periodically provides the internationally accepted set of values of the fundamental physical constants. This package contains the "2018 CODATA" version, published on May 2019: Eite Tiesinga, Peter J. Mohr, David B. Newell, and Barry N. Taylor (2020) <https://physics.nist.gov/cuu/Constants/>.

constants: Reference on Constants, Units and Uncertainty

BuildStatus CoverageStatus CRAN_Status_Badge Downloads

The constants package provides the CODATA internationally recommended values of the fundamental physical constants, provided as symbols for direct use within the R language. Optionally, the values with uncertainties and/or units are also provided if the ‘errors’, ‘units’ and/or ‘quantities’ packages are installed. The Committee on Data for Science and Technology (CODATA) is an interdisciplinary committee of the International Council for Science which periodically provides the internationally accepted set of values of the fundamental physical constants. This package contains the “2018 CODATA” version, published on May 2019.

Eite Tiesinga, Peter J. Mohr, David B. Newell, and Barry N. Taylor (2020). The 2018 CODATA Recommended Values of the Fundamental Physical Constants (Web Version 8.1). Database developed by J. Baker, M. Douma, and S. Kotochigova. Available at https://physics.nist.gov/cuu/Constants/, National Institute of Standards and Technology, Gaithersburg, MD 20899.

Installation

Install the release version from CRAN:

install.packages("constants")

The installation from GitHub requires the remotes package.

# install.packages("remotes")
remotes::install_github("r-quantities/constants")

Example

library(constants)

# the speed of light
syms$c0
#> [1] 299792458
# use the constants in a local environment
with(syms, c0)
#> [1] 299792458

# explore which constants are available
(lkp <- lookup("planck", ignore.case=TRUE))
#>        symbol                                  quantity
#> 137       nah                     molar Planck constant
#> 198         h                           Planck constant
#> 199       hev                  Planck constant in eV/Hz
#> 200      plkl                             Planck length
#> 201      plkm                               Planck mass
#> 202 plkmc2gev      Planck mass energy equivalent in GeV
#> 203    plktmp                        Planck temperature
#> 204      plkt                               Planck time
#> 230      hbar                   reduced Planck constant
#> 231    hbarev           reduced Planck constant in eV s
#> 232   hbcmevf reduced Planck constant times c in MeV fm
#>                          type        value uncertainty     unit
#> 137          Physico-chemical 3.990313e-10     0.0e+00 J/Hz/mol
#> 198 Universal, Adopted values 6.626070e-34     0.0e+00     J/Hz
#> 199                 Universal 4.135668e-15     0.0e+00    eV/Hz
#> 200                 Universal 1.616255e-35     1.8e-40        m
#> 201                 Universal 2.176434e-08     2.4e-13       kg
#> 202                 Universal 1.220890e+19     1.4e+14      GeV
#> 203                 Universal 1.416784e+32     1.6e+27        K
#> 204                 Universal 5.391247e-44     6.0e-49        s
#> 230 Universal, Adopted values 1.054572e-34     0.0e+00      J*s
#> 231                 Universal 6.582120e-16     0.0e+00     eV*s
#> 232   Universal, Non-SI units 1.973270e+02     0.0e+00   fm*MeV
idx <- as.integer(rownames(lkp))

# attach the symbols to the search path and use them explicitly
attach(syms[idx])
h
#> [1] 6.62607e-34
plkl
#> [1] 1.616255e-35

# the same with uncertainty
detach(syms[idx])
attach(syms_with_errors[idx])
h
#> 6.62607(0)e-34
plkl
#> 1.61626(2)e-35

# the same with units
detach(syms_with_errors[idx])
attach(syms_with_units[idx])
h
#> 6.62607e-34 [J/Hz]
plkl
#> 1.616255e-35 [m]

# the same with everything
detach(syms_with_units[idx])
attach(syms_with_quantities[idx])
h
#> 6.62607(0)e-34 [J/Hz]
plkl
#> 1.61626(2)e-35 [m]

# the whole dataset
head(codata)
#>     symbol                                     quantity               type
#> 1      mal                          alpha particle mass Atomic and nuclear
#> 2    malc2        alpha particle mass energy equivalent Atomic and nuclear
#> 3 malc2mev alpha particle mass energy equivalent in MeV Atomic and nuclear
#> 4     malu                     alpha particle mass in u Atomic and nuclear
#> 5     mmal                    alpha particle molar mass Atomic and nuclear
#> 6   malsme           alpha particle-electron mass ratio Atomic and nuclear
#>          value uncertainty   unit
#> 1 6.644657e-27     2.0e-36     kg
#> 2 5.971920e-10     1.8e-19      J
#> 3 3.727379e+03     1.1e-06    MeV
#> 4 4.001506e+00     6.3e-11      u
#> 5 4.001506e-03     1.2e-12 kg/mol
#> 6 7.294300e+03     2.4e-07      1

# number of constants per type
library(magrittr)
codata %>%
  tidyr::separate_rows(type, sep=", ") %>%
  dplyr::count(type, sort=TRUE)
#> # A tibble: 8 x 2
#>   type                   n
#>   <chr>              <int>
#> 1 Atomic and nuclear   173
#> 2 <NA>                  68
#> 3 Non-SI units          36
#> 4 Electromagnetic       26
#> 5 Physico-chemical      25
#> 6 Universal             16
#> 7 Adopted values        11
#> 8 X-ray values           6
Metadata

Version

1.0.1

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows