diff options
author | wm624@hotmail.com <wm624@hotmail.com> | 2016-12-13 18:52:05 -0800 |
---|---|---|
committer | Yanbo Liang <ybliang8@gmail.com> | 2016-12-13 18:52:05 -0800 |
commit | f2ddabfa09fda26ff0391d026dd67545dab33e01 (patch) | |
tree | 8914c58e15d1db25c15e650d72aef89c00f4e797 /R | |
parent | e104e55c16e229e521c517393b8163cbc3bbf85a (diff) | |
download | spark-f2ddabfa09fda26ff0391d026dd67545dab33e01.tar.gz spark-f2ddabfa09fda26ff0391d026dd67545dab33e01.tar.bz2 spark-f2ddabfa09fda26ff0391d026dd67545dab33e01.zip |
[MINOR][SPARKR] fix kstest example error and add unit test
## What changes were proposed in this pull request?
While adding vignettes for kstest, I found some errors in the example:
1. There is a typo of kstest;
2. print.summary.KStest doesn't work with the example;
Fix the example errors;
Add a new unit test for print.summary.KStest;
## How was this patch tested?
Manual test;
Add new unit test;
Author: wm624@hotmail.com <wm624@hotmail.com>
Closes #16259 from wangmiao1981/ks.
Diffstat (limited to 'R')
-rw-r--r-- | R/pkg/R/mllib.R | 4 | ||||
-rw-r--r-- | R/pkg/inst/tests/testthat/test_mllib.R | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/R/pkg/R/mllib.R b/R/pkg/R/mllib.R index 5df843c2b9..d736bbb5e9 100644 --- a/R/pkg/R/mllib.R +++ b/R/pkg/R/mllib.R @@ -1595,14 +1595,14 @@ setMethod("write.ml", signature(object = "ALSModel", path = "character"), #' \dontrun{ #' data <- data.frame(test = c(0.1, 0.15, 0.2, 0.3, 0.25)) #' df <- createDataFrame(data) -#' test <- spark.ktest(df, "test", "norm", c(0, 1)) +#' test <- spark.kstest(df, "test", "norm", c(0, 1)) #' #' # get a summary of the test result #' testSummary <- summary(test) #' testSummary #' #' # print out the summary in an organized way -#' print.summary.KSTest(test) +#' print.summary.KSTest(testSummary) #' } #' @note spark.kstest since 2.1.0 setMethod("spark.kstest", signature(data = "SparkDataFrame"), diff --git a/R/pkg/inst/tests/testthat/test_mllib.R b/R/pkg/inst/tests/testthat/test_mllib.R index 986af4a0c5..0f0d831c6f 100644 --- a/R/pkg/inst/tests/testthat/test_mllib.R +++ b/R/pkg/inst/tests/testthat/test_mllib.R @@ -986,6 +986,12 @@ test_that("spark.kstest", { expect_equal(stats$p.value, rStats$p.value, tolerance = 1e-4) expect_equal(stats$statistic, unname(rStats$statistic), tolerance = 1e-4) expect_match(capture.output(stats)[1], "Kolmogorov-Smirnov test summary:") + + # Test print.summary.KSTest + printStats <- capture.output(print.summary.KSTest(stats)) + expect_match(printStats[1], "Kolmogorov-Smirnov test summary:") + expect_match(printStats[5], + "Low presumption against null hypothesis: Sample follows theoretical distribution. ") }) test_that("spark.randomForest", { |