Can I recalculate the analysis in R? (R script)
In brief
Statable can give you an analysis as an R script. R is free statistics software; a script is a text file with commands. With the script, R calculates the same analysis again and arrives at the same numbers. This way an analysis can be checked, documented in a thesis or taken further in R.
How to do it in Statable
- One result: open "Export ▾" in the result and choose "As R script with data (.zip)".
- The whole report: on the page "Report" choose "As R script (.zip)". Each page stands on its own in the script, so the pages do not disturb each other.
The ZIP file contains the script (ending .R) and a CSV file with the columns the analysis needs, in UTF-8 and with a point as decimal sign.
Starting it in R
- Unzip the ZIP file.
- Open R or RStudio and change to the unzipped folder: in R with setwd(), in RStudio via Session > Set Working Directory > To Source File Location.
- Run the script with source() and the file name, or go through it line by line in RStudio.
The script needs only R itself and the packages MASS and nnet, which come with every R installation. It downloads nothing from the internet.
For which analyses
Among others: t-test, analysis of variance, before-after comparison, correlation (also partial), crosstab, linear and logistic regression, distribution, scale and reliability (also split-half), kappa, ICC, rank tests (Mann-Whitney, Kruskal-Wallis, Wilcoxon), repeated measures, factor analysis and ordinal, multinomial and count regression. Where there is no script, the menu has no entry; in the script of the report such pages are listed at the top.
What is often misunderstood
- With a frequency weight (case weight) the script repeats each row as often as its weight says, as PSPP and SPSS do. A survey weight works differently; there is no script for it.
- The numbers match Statable up to rounding; this is checked against R itself. Small differences in the last digit come from calculating with decimal numbers.
- The script does not contain the data in its text but reads them from the CSV file. Whoever may not pass on the data passes on only the script.