Repository: spark Updated Branches: refs/heads/master 417140e44 -> 2ff1467d6
[DOC][MINOR][SPARKR] Update SparkR doc for names, columns and colnames Update R doc: 1. columns, names and colnames returns a vector of strings, not **list** as in current doc. 2. `colnames<-` does allow the subset assignment, so the length of `value` can be less than the number of columns, e.g., `colnames(df)[1] <- "a"`. felixcheung Author: actuaryzhang <actuaryzhan...@gmail.com> Closes #17115 from actuaryzhang/sparkRMinorDoc. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2ff1467d Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2ff1467d Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2ff1467d Branch: refs/heads/master Commit: 2ff1467d676c9671da231db86bdc8e09c7450f80 Parents: 417140e Author: actuaryzhang <actuaryzhan...@gmail.com> Authored: Wed Mar 1 12:35:56 2017 -0800 Committer: Felix Cheung <felixche...@apache.org> Committed: Wed Mar 1 12:35:56 2017 -0800 ---------------------------------------------------------------------- R/pkg/R/DataFrame.R | 4 ++-- R/pkg/inst/tests/testthat/test_sparkSQL.R | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/2ff1467d/R/pkg/R/DataFrame.R ---------------------------------------------------------------------- diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R index cc4cfa3..e33d0d8 100644 --- a/R/pkg/R/DataFrame.R +++ b/R/pkg/R/DataFrame.R @@ -280,7 +280,7 @@ setMethod("dtypes", #' Column Names of SparkDataFrame #' -#' Return all column names as a list. +#' Return a vector of column names. #' #' @param x a SparkDataFrame. #' @@ -338,7 +338,7 @@ setMethod("colnames", }) #' @param value a character vector. Must have the same length as the number -#' of columns in the SparkDataFrame. +#' of columns to be renamed. #' @rdname columns #' @aliases colnames<-,SparkDataFrame-method #' @name colnames<- http://git-wip-us.apache.org/repos/asf/spark/blob/2ff1467d/R/pkg/inst/tests/testthat/test_sparkSQL.R ---------------------------------------------------------------------- diff --git a/R/pkg/inst/tests/testthat/test_sparkSQL.R b/R/pkg/inst/tests/testthat/test_sparkSQL.R index ce0f5a1..1dd8c5c 100644 --- a/R/pkg/inst/tests/testthat/test_sparkSQL.R +++ b/R/pkg/inst/tests/testthat/test_sparkSQL.R @@ -898,6 +898,12 @@ test_that("names() colnames() set the column names", { expect_equal(names(z)[3], "c") names(z)[3] <- "c2" expect_equal(names(z)[3], "c2") + + # Test subset assignment + colnames(df)[1] <- "col5" + expect_equal(colnames(df)[1], "col5") + names(df)[2] <- "col6" + expect_equal(names(df)[2], "col6") }) test_that("head() and first() return the correct data", { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org