Do I need to use `jmvcore::toNumeric()` if we are using `permitted: - numeric`
Posted: Sun Jan 25, 2026 2:42 pm
I am developing a module and looking for clarification on best practices for handling data types.
I noticed a pattern in the core `jmv` modules (for example, in the **Independent Samples T-Test** `ttestIS`).
In **`ttestIS.a.yaml`**, the variables are strictly defined with:
```yaml
permitted:
- numeric
```
This restricts the user to selecting only numeric/continuous variables in the UI.
However, in the corresponding backend code (**`ttestIS.b.R`**), there is still an explicit conversion:
```r
data[[name]] <- jmvcore::toNumeric(data[[name]])
```
**My Question:**
Is this call to `toNumeric()` redundant if the UI already enforces the type? Or does `toNumeric()` serve a critical safety role (e.g., stripping attributes or handling specific edge cases) that makes it mandatory even for ensuring "pure" numeric vectors?
Thanks!
I noticed a pattern in the core `jmv` modules (for example, in the **Independent Samples T-Test** `ttestIS`).
In **`ttestIS.a.yaml`**, the variables are strictly defined with:
```yaml
permitted:
- numeric
```
This restricts the user to selecting only numeric/continuous variables in the UI.
However, in the corresponding backend code (**`ttestIS.b.R`**), there is still an explicit conversion:
```r
data[[name]] <- jmvcore::toNumeric(data[[name]])
```
**My Question:**
Is this call to `toNumeric()` redundant if the UI already enforces the type? Or does `toNumeric()` serve a critical safety role (e.g., stripping attributes or handling specific edge cases) that makes it mandatory even for ensuring "pure" numeric vectors?
Thanks!