diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R index 841e77e55e0d8..a64d1e6b3ea5b 100644 --- a/R/pkg/R/DataFrame.R +++ b/R/pkg/R/DataFrame.R @@ -147,14 +147,14 @@ setMethod("isLocal", callJMethod(x@sdf, "isLocal") }) -#' ShowDF +#' show #' #' Print the first numRows rows of a DataFrame #' #' @param x A SparkSQL DataFrame #' @param numRows The number of rows to print. Defaults to 20. #' -#' @rdname showDF +#' @rdname show #' @export #' @examples #'\dontrun{ @@ -162,21 +162,21 @@ setMethod("isLocal", #' sqlCtx <- sparkRSQL.init(sc) #' path <- "path/to/file.json" #' df <- jsonFile(sqlCtx, path) -#' showDF(df) +#' show(df) #'} -setMethod("showDF", +setMethod("show", signature(x = "DataFrame"), function(x, numRows = 20) { callJMethod(x@sdf, "showString", numToInt(numRows)) }) -#' show +#' showDF #' #' Print the DataFrame column names and types #' #' @param x A SparkSQL DataFrame #' -#' @rdname show +#' @rdname showDF #' @export #' @examples #'\dontrun{ @@ -184,9 +184,9 @@ setMethod("showDF", #' sqlCtx <- sparkRSQL.init(sc) #' path <- "path/to/file.json" #' df <- jsonFile(sqlCtx, path) -#' show(df) +#' showDF #'} -setMethod("show", "DataFrame", +setMethod("showDF", "DataFrame", function(object) { cols <- lapply(dtypes(object), function(l) { paste(l, collapse = ":") diff --git a/R/pkg/inst/tests/test_sparkSQL.R b/R/pkg/inst/tests/test_sparkSQL.R index f82e56fdd8278..a8f79bdadc2b5 100644 --- a/R/pkg/inst/tests/test_sparkSQL.R +++ b/R/pkg/inst/tests/test_sparkSQL.R @@ -639,9 +639,9 @@ test_that("toJSON() returns an RDD of the correct values", { expect_equal(collect(testRDD)[[1]], mockLines[1]) }) -test_that("showDF()", { +test_that("show()", { df <- jsonFile(sqlCtx, jsonPath) - expect_output(showDF(df), "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n") + expect_output(show(df), "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n") }) test_that("isLocal()", {