| safe_sqrt | R Documentation |
Computes sqrt(x) with protection against negative inputs.
Negative values are clamped to min_val before taking the root.
safe_sqrt(x, min_val = 0, warn = TRUE, param_name = "value")
x |
Numeric value or vector |
min_val |
Minimum value before sqrt, default 0 |
warn |
Logical; issue a warning when clamping occurs, default TRUE |
param_name |
Name used in warning messages |
sqrt(x), or sqrt(min_val) for negative values
safe_sqrt(4)
suppressWarnings(safe_sqrt(-1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.