[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 <actuaryzhang10@gmail.com>

Closes #17115 from actuaryzhang/sparkRMinorDoc.
This commit is contained in:
actuaryzhang 2017-03-01 12:35:56 -08:00 committed by Felix Cheung
parent 417140e441
commit 2ff1467d67
2 changed files with 8 additions and 2 deletions

View file

@ -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<-

View file

@ -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", {