# The R script (/docs/r-script)



Every analysis report that has R shows a &#x2A;*Reproducibility (R)** block with the emitted script, below the result. SPSS syntax is separate, under &#x2A;*SPSS syntax (reference)**.

The script loads your download as:

```r
df <- read.csv("dataset.csv", stringsAsFactors = FALSE, check.names = FALSE,
               na.strings = c('', 'NA', 'null', 'NULL'))
```

Identity comments at the top are `# dataset_id:` and `# source: dataset.csv`.

## Badges [#badges]

The **R syntax** badge is on engine analyses, not plugins. The live allow-list is `_BADGE` in `app/r_coverage.py`: when Rscript can run, those keys stamp `verified` or `not_verified`; without Rscript they can stamp `verified_in_ci` on this build.

| Kind             | Default text                                                      |
| ---------------- | ----------------------------------------------------------------- |
| `verified`       | R syntax reproduced F, df and n.                                  |
| `verified_in_ci` | This syntax reproduced against a reference dataset on this build. |
| `not_verified`   | Generated R does not reproduce the engine result.                 |
| `unknown`        | R syntax reproduction unknown.                                    |

`not_verified` is the amber state. The live statement on the badge can be more specific (for example ANOVA includes ΔF and Δn). Keys that are not in `_BADGE` stay `unknown`.

`_BADGE` keys: anova\_oneway, anova\_twoway, linear\_regression, logistic\_regression, descriptives, correlation, ttest\_one\_sample, ttest\_paired, stepwise\_regression, anova\_mixed, mixed\_anova, mann\_whitney\_u, wilcoxon\_signed\_rank, kruskal\_wallis, friedman, sign\_test, median\_test, anova\_repeated, rm\_anova, anova\_threeway, ancova, manova, hotelling\_t2, hierarchical\_regression, moderation\_analysis, poisson\_regression, probit\_regression, negative\_binomial\_regression, ordinal\_regression, partial\_correlation, multilevel\_modelling, fishers\_exact, odds\_ratio, relative\_risk, mcnemar, cochrans\_q, mantel\_haenszel, cochran\_armitage, cohens\_kappa, weighted\_kappa, fleiss\_kappa, kendalls\_w, goodman\_kruskal\_gamma, goodman\_kruskal\_lambda, somers\_d, loglinear, jonckheere\_terpstra, moses\_test, runs\_test, kolmogorov\_smirnov, lilliefors\_ks, shapiro\_wilk, linear\_mixed\_model, mixed\_model, ttest\_independent, chi\_square, reliability, reliability\_cronbach, pca, kaplan\_meier, cox\_proportional\_hazards, nelson\_aalen, autocorrelation, nps, gee, generalized\_linear\_mixed\_model, banner\_table, batch\_tables, rake, poststratify, merge\_datasets, fuse\_waves, set\_active\_weight, turf, maxdiff\_count, van\_westendorp, gabor\_granger, funnel, drivers, choice\_simulator, confirmatory\_factor\_analysis, structural\_equation\_modelling, efa, cluster\_analysis, discriminant\_analysis, canonical\_correlation, correspondence, multidimensional\_scaling, arima\_sarima, exponential\_smoothing, stl\_decomposition, stationarity\_tests, network, dbscan, latent\_class\_analysis, maxdiff\_mnl, conjoint\_mnl.

## Not compared to R (`NOT_VERIFIABLE` in the same file) [#not-compared-to-r-not_verifiable-in-the-same-file]

The badge stays off. Reasons from `r_coverage.py`:

* Open-text coding — an agent procedure, not a statistic with an R equivalent
* Decision tree — sklearn DecisionTree vs rpart splits differ; CART implementations are not aligned
* Random forest classification and regression — sklearn RandomForest vs randomForest; trees are not aligned across libraries
* Gradient boosting — sklearn GradientBoosting vs gbm; boosting paths differ
* SVM classification — sklearn SVC vs e1071::svm kernels/solvers differ
* Neural network (MLP) — sklearn MLP vs nnet; random init and architecture differ
* MaxDiff HB — penalized mixed-logit HB is not Sawtooth and has no unique R reference
* Conjoint HB — penalized mixed-logit CBC is not Sawtooth and has no unique R reference

## How to run it [#how-to-run-it]

1. Export the dataset as CSV (same names as the `.sav`, including `weight` when present).
2. Save the emitted script next to `dataset.csv`.
3. Run `Rscript your-script.R`. Tensr uses `RSCRIPT_BIN` if set, otherwise `Rscript`.

Packages the runner expects include `jsonlite`, `dplyr`, `irr`, `epitools`, `DescTools`, `ez`, `ggplot2`, and analysis-specific libraries such as `car`, `lme4`, `MASS`, `survival`, and `geepack`.

Open-text coding emits a comment only: it is not a stats engine call.
