diff --git a/R/Wilcoxon.R b/R/Wilcoxon.R index 02bf7ac4..5c74ab53 100644 --- a/R/Wilcoxon.R +++ b/R/Wilcoxon.R @@ -72,9 +72,9 @@ Wilcoxon <- R6Class( }, .calculate_extra = function() { - x <- private$.raw_data$x - y <- private$.raw_data$y - + x <- private$.raw_data[[1]] + y <- private$.raw_data[[2]] + diff <- as.vector(outer(x, y, "-")) private$.estimate <- median(diff) diff --git a/README.Rmd b/README.Rmd index 7d610644..ce89b00e 100644 --- a/README.Rmd +++ b/README.Rmd @@ -40,6 +40,10 @@ pak::pkg_install("qddyy/LearnNonparam") ## Usage +```{r} +set.seed(2023) +``` + - Create a test object (for example, a `Wilcoxon` object) ```{r, eval = FALSE} t <- Wilcoxon$new(alternative = "greater", type = "permu", n_permu = 1e7) @@ -52,7 +56,6 @@ pak::pkg_install("qddyy/LearnNonparam") - Test some data (`vector` | `data.frame` | `list`) ```{r, test} - set.seed(2023) t$test(rnorm(20, mean = 1), rnorm(20, mean = 0)) ``` diff --git a/README.md b/README.md index dff2a59e..8b613a76 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ pak::pkg_install("qddyy/LearnNonparam") ## Usage +``` r +set.seed(2023) +``` + - Create a test object (for example, a `Wilcoxon` object) ``` r @@ -44,7 +48,6 @@ pak::pkg_install("qddyy/LearnNonparam") - Test some data (`vector` \| `data.frame` \| `list`) ``` r - set.seed(2023) t$test(rnorm(20, mean = 1), rnorm(20, mean = 0)) ``` @@ -61,8 +64,8 @@ pak::pkg_install("qddyy/LearnNonparam") #> scoring: rank type: permu(1e+07) method: default #> statistic = 475, p_value = 0.041 #> alternative hypothesis: true location shift is greater than 0 - #> estimate: NA - #> 95% confidence interval: NA NA + #> estimate: 0.52 + #> 95% confidence interval: -0.064 1.284 t$plot(style = "ggplot2", binwidth = 1) #> Loading required namespace: ggplot2 diff --git a/man/figures/README-results-1.svg b/man/figures/README-results-1.svg index 5847d310..14fed6f8 100644 --- a/man/figures/README-results-1.svg +++ b/man/figures/README-results-1.svg @@ -163,7 +163,7 @@ - +