View source: R/wilcoxon_test.R
| wilcoxon_test | R Documentation |
Perform a Wilcoxon signed rank test for a paired sample or a Wilcoxon rank sum test for independent samples on variables of a data set. The output is printed as a LaTeX table that mimics the look of SPSS output.
wilcoxon_test(data, variables, group = NULL, exact = FALSE)
## S3 method for class 'wilcoxon_test_SPSS'
to_SPSS(
object,
statistics = c("test", "ranks"),
version = r2spss_options$get("version"),
digits = NULL,
...
)
## S3 method for class 'wilcoxon_test_SPSS'
print(
x,
statistics = c("ranks", "test"),
version = r2spss_options$get("version"),
digits = 2:3,
...
)
wilcoxonTest(data, variables, group = NULL, exact = FALSE)
data |
a data frame containing the variables. |
variables |
a character vector specifying numeric variable(s) to be
used. If |
group |
a character string specifying a grouping variable for the
Wilcoxon rank sum test, or |
exact |
a logical indicating whether the Wilcoxon rank sum test
should also return the p-value of the exact test. The default is
|
object, x |
an object of class |
statistics |
a character string or vector specifying which SPSS tables
to produce. Available options are |
version |
a character string specifying whether the table should
mimic the content and look of recent SPSS versions ( |
digits |
for the |
... |
additional arguments to be passed down to
|
The print method first calls the to_SPSS method followed
by to_latex. Further customization can be done by calling
those two functions separately, and modifying the object returned by
to_SPSS.
An object of class "wilcoxon_test_SPSS" with the following
components:
statisticsa data frame containing the relevant information on the ranks.
testa list containing the results of the Wilcoxon signed rank test (only paired-sample test).
variablesa character vector containing the name(s) of the relevant numeric variable(s).
nan integer giving the number of observations (only paired-sample test).
unumeric; the Mann-Whitney U test statistic (only independent-samples test).
wnumeric; the Wilcoxon rank sum test statistic (only independent-samples test).
asymptotica list containing the results of the Wilcoxon rank sum test using the normal approximation (only independent-samples test).
exactif requested, the corresponding p-value of the exact Wilcoxon rank sum test test (only independent-samples test).
groupa character string containing the name of the grouping variable (only independent-samples test).
typea character string giving the type of Wilcoxon test
performed "paired" or "independent").
The to_SPSS method returns an object of class "SPSS_table"
which contains all relevant information in the required format to produce
the LaTeX table. See to_latex for possible components and
how to further customize the LaTeX table based on the returned object.
The print method produces a LaTeX table that mimics the look of SPSS
output.
The Wilcoxon rank sum test also reports the value of the equivalent Mann-Whitney U test statistic.
LaTeX tables that mimic recent versions of SPSS (version = "modern")
may require several LaTeX compilations to be displayed correctly.
Andreas Alfons
## paired sample
# load data
data("Exams")
# test whether grades differ between the
# regular exam and the resit
wilcoxon_test(Exams, c("Regular", "Resit"))
## independent samples
# load data
data("Eredivisie")
# test whether market values differ between Dutch and foreign
# players
wilcoxon_test(Eredivisie, "MarketValue", group = "Foreign")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.