Assign a value to a variable if it does not already exist in the specified environment
Source:R/General_AssignIfNotExist.R
AssignIfNotExist.Rd
This function checks if a given variable exists in the specified environment (global environment by default). If the variable does not exist, it assigns a given value to it. If the variable already exists, it prints the current value of the variable. The function is designed to prevent overwriting existing variables unintentionally.
Usage
AssignIfNotExist(Variable, Value, Env = globalenv())
Arguments
- Variable
Character; the name of the variable to be checked and potentially assigned a value.
- Value
any; the value to be assigned to the variable if it does not already exist.
- Env
environment; the environment in which to check for the existence of the variable and potentially assign the value. Defaults to the global environment.