Repository: spark
Updated Branches:
  refs/heads/branch-2.1 07a1788ee -> e43f161bb


[BACKPORT-2.1][SPARKR][DOCS] update R API doc for subset/extract

## What changes were proposed in this pull request?

backport #16721 to branch-2.1

## How was this patch tested?

manual

Author: Felix Cheung <[email protected]>

Closes #16749 from felixcheung/rsubsetdocbackport.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/e43f161b
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/e43f161b
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/e43f161b

Branch: refs/heads/branch-2.1
Commit: e43f161bbe04d2dc2af1e2f9280d4d0b47392acf
Parents: 07a1788
Author: Felix Cheung <[email protected]>
Authored: Mon Jan 30 22:14:58 2017 -0800
Committer: Felix Cheung <[email protected]>
Committed: Mon Jan 30 22:14:58 2017 -0800

----------------------------------------------------------------------
 R/pkg/R/DataFrame.R                  | 15 +++++++++++++--
 R/pkg/R/mllib.R                      | 10 +++++-----
 R/pkg/vignettes/sparkr-vignettes.Rmd |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/e43f161b/R/pkg/R/DataFrame.R
----------------------------------------------------------------------
diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R
index 39e8376..c960b45 100644
--- a/R/pkg/R/DataFrame.R
+++ b/R/pkg/R/DataFrame.R
@@ -936,7 +936,7 @@ setMethod("unique",
 
 #' Sample
 #'
-#' Return a sampled subset of this SparkDataFrame using a random seed. 
+#' Return a sampled subset of this SparkDataFrame using a random seed.
 #' Note: this is not guaranteed to provide exactly the fraction specified
 #' of the total count of of the given SparkDataFrame.
 #'
@@ -1825,6 +1825,8 @@ setMethod("[", signature(x = "SparkDataFrame"),
 #' Return subsets of SparkDataFrame according to given conditions
 #' @param x a SparkDataFrame.
 #' @param i,subset (Optional) a logical expression to filter on rows.
+#'                 For extract operator [[ and replacement operator [[<-, the 
indexing parameter for
+#'                 a single Column.
 #' @param j,select expression for the single Column or a list of columns to 
select from the SparkDataFrame.
 #' @param drop if TRUE, a Column will be returned if the resulting dataset has 
only one column.
 #'             Otherwise, a SparkDataFrame will always be returned.
@@ -1835,6 +1837,7 @@ setMethod("[", signature(x = "SparkDataFrame"),
 #' @export
 #' @family SparkDataFrame functions
 #' @aliases subset,SparkDataFrame-method
+#' @seealso \link{withColumn}
 #' @rdname subset
 #' @name subset
 #' @family subsetting functions
@@ -1852,6 +1855,10 @@ setMethod("[", signature(x = "SparkDataFrame"),
 #'   subset(df, df$age %in% c(19, 30), 1:2)
 #'   subset(df, df$age %in% c(19), select = c(1,2))
 #'   subset(df, select = c(1,2))
+#'   # Columns can be selected and set
+#'   df[["age"]] <- 23
+#'   df[[1]] <- df$age
+#'   df[[2]] <- NULL # drop column
 #' }
 #' @note subset since 1.5.0
 setMethod("subset", signature(x = "SparkDataFrame"),
@@ -1976,7 +1983,7 @@ setMethod("selectExpr",
 #' @aliases withColumn,SparkDataFrame,character-method
 #' @rdname withColumn
 #' @name withColumn
-#' @seealso \link{rename} \link{mutate}
+#' @seealso \link{rename} \link{mutate} \link{subset}
 #' @export
 #' @examples
 #'\dontrun{
@@ -1987,6 +1994,10 @@ setMethod("selectExpr",
 #' # Replace an existing column
 #' newDF2 <- withColumn(newDF, "newCol", newDF$col1)
 #' newDF3 <- withColumn(newDF, "newCol", 42)
+#' # Use extract operator to set an existing or new column
+#' df[["age"]] <- 23
+#' df[[2]] <- df$col1
+#' df[[2]] <- NULL # drop column
 #' }
 #' @note withColumn since 1.4.0
 setMethod("withColumn",

http://git-wip-us.apache.org/repos/asf/spark/blob/e43f161b/R/pkg/R/mllib.R
----------------------------------------------------------------------
diff --git a/R/pkg/R/mllib.R b/R/pkg/R/mllib.R
index 1a254ad..91ce669 100644
--- a/R/pkg/R/mllib.R
+++ b/R/pkg/R/mllib.R
@@ -173,7 +173,7 @@ predict_internal <- function(object, newData) {
 
 #' Generalized Linear Models
 #'
-#' Fits generalized linear model against a Spark DataFrame.
+#' Fits generalized linear model against a SparkDataFrame.
 #' Users can call \code{summary} to print a summary of the fitted model, 
\code{predict} to make
 #' predictions on new data, and \code{write.ml}/\code{read.ml} to save/load 
fitted models.
 #'
@@ -499,7 +499,7 @@ setMethod("write.ml", signature(object = "LDAModel", path = 
"character"),
 
 #' Isotonic Regression Model
 #'
-#' Fits an Isotonic Regression model against a Spark DataFrame, similarly to 
R's isoreg().
+#' Fits an Isotonic Regression model against a SparkDataFrame, similarly to 
R's isoreg().
 #' Users can print, make predictions on the produced model and save the model 
to the input path.
 #'
 #' @param data SparkDataFrame for training.
@@ -588,7 +588,7 @@ setMethod("summary", signature(object = 
"IsotonicRegressionModel"),
 
 #' K-Means Clustering Model
 #'
-#' Fits a k-means clustering model against a Spark DataFrame, similarly to R's 
kmeans().
+#' Fits a k-means clustering model against a SparkDataFrame, similarly to R's 
kmeans().
 #' Users can call \code{summary} to print a summary of the fitted model, 
\code{predict} to make
 #' predictions on new data, and \code{write.ml}/\code{read.ml} to save/load 
fitted models.
 #'
@@ -712,7 +712,7 @@ setMethod("predict", signature(object = "KMeansModel"),
 
 #' Logistic Regression Model
 #'
-#' Fits an logistic regression model against a Spark DataFrame. It supports 
"binomial": Binary logistic regression
+#' Fits an logistic regression model against a SparkDataFrame. It supports 
"binomial": Binary logistic regression
 #' with pivoting; "multinomial": Multinomial logistic (softmax) regression 
without pivoting, similar to glmnet.
 #' Users can print, make predictions on the produced model and save the model 
to the input path.
 #'
@@ -1321,7 +1321,7 @@ setMethod("predict", signature(object = 
"AFTSurvivalRegressionModel"),
 
 #' Multivariate Gaussian Mixture Model (GMM)
 #'
-#' Fits multivariate gaussian mixture model against a Spark DataFrame, 
similarly to R's
+#' Fits multivariate gaussian mixture model against a SparkDataFrame, 
similarly to R's
 #' mvnormalmixEM(). Users can call \code{summary} to print a summary of the 
fitted model,
 #' \code{predict} to make predictions on new data, and 
\code{write.ml}/\code{read.ml}
 #' to save/load fitted models.

http://git-wip-us.apache.org/repos/asf/spark/blob/e43f161b/R/pkg/vignettes/sparkr-vignettes.Rmd
----------------------------------------------------------------------
diff --git a/R/pkg/vignettes/sparkr-vignettes.Rmd 
b/R/pkg/vignettes/sparkr-vignettes.Rmd
index 9b0ded3..36a7847 100644
--- a/R/pkg/vignettes/sparkr-vignettes.Rmd
+++ b/R/pkg/vignettes/sparkr-vignettes.Rmd
@@ -923,9 +923,9 @@ The main method calls of actual computation happen in the 
Spark JVM of the drive
 
 Two kinds of RPCs are supported in the SparkR JVM backend: method invocation 
and creating new objects. Method invocation can be done in two ways.
 
-* `sparkR.invokeJMethod` takes a reference to an existing Java object and a 
list of arguments to be passed on to the method.
+* `sparkR.callJMethod` takes a reference to an existing Java object and a list 
of arguments to be passed on to the method.
 
-* `sparkR.invokeJStatic` takes a class name for static method and a list of 
arguments to be passed on to the method.
+* `sparkR.callJStatic` takes a class name for static method and a list of 
arguments to be passed on to the method.
 
 The arguments are serialized using our custom wire format which is then 
deserialized on the JVM side. We then use Java reflection to invoke the 
appropriate method.
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to