The goal of const is to allow users to create constants, rather than variables. Once a constant has been defined, its value cannot be changed.
<STYLE type='text/css' scoped> PRE.fansi SPAN {padding-top: .25em; padding-bottom: .25em}; </STYLE>You can install the released version of const from CRAN with:
install.packages("const")
And the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("MyKo101/const")
To create a constant within R, you can use the :=
assignment operator
library(const)
#> Warning: package 'const' was built under R version 4.1.0
x := "hello world"
x
#> <const>
#> [1] "hello world"
Here, x
, is now a constant and cannot be changed
x := 2
#> Error: x := 2
#> Cannot re-assign constant.
To delete a constant, use rm()
rm(x)