How to create a constant inside an R package?

How to create a constant variable inside an R-package whose value cannot be changed? In other words, how can we block the value of a pair name in a package environment?

Example: in my package, I use the normal distribution quantile in cycles of various functions and do not want to constantly calculate (or create) it.

I tried k_q3 <- qnorm(1 - 0.01/2); lockBinding("k_q3", environment()) k_q3 <- qnorm(1 - 0.01/2); lockBinding("k_q3", environment()) , but it does not work.

UPDATE: the above method is working. You cannot change k_q3 either inside the package or outside.

+6
source share

All Articles