diff options
author | Oscar D. Lara Yejas <olarayej@mail.usf.edu> | 2015-09-30 18:03:31 -0700 |
---|---|---|
committer | Shivaram Venkataraman <shivaram@cs.berkeley.edu> | 2015-09-30 18:03:31 -0700 |
commit | f21e2da03fbf8041fece476e3d5c699aef819451 (patch) | |
tree | 5e9d949731b60b599b444bea906167bba2e23ed3 /R/pkg/R/DataFrame.R | |
parent | 89ea0041ae5a701ce8d211ed08f1f059b7f9c396 (diff) | |
download | spark-f21e2da03fbf8041fece476e3d5c699aef819451.tar.gz spark-f21e2da03fbf8041fece476e3d5c699aef819451.tar.bz2 spark-f21e2da03fbf8041fece476e3d5c699aef819451.zip |
[SPARK-10807] [SPARKR] Added as.data.frame as a synonym for collect
Created method as.data.frame as a synonym for collect().
Author: Oscar D. Lara Yejas <olarayej@mail.usf.edu>
Author: olarayej <oscar.lara.yejas@us.ibm.com>
Author: Oscar D. Lara Yejas <oscar.lara.yejas@us.ibm.com>
Closes #8908 from olarayej/SPARK-10807.
Diffstat (limited to 'R/pkg/R/DataFrame.R')
-rw-r--r-- | R/pkg/R/DataFrame.R | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R index c3c1893487..65e368c47d 100644 --- a/R/pkg/R/DataFrame.R +++ b/R/pkg/R/DataFrame.R @@ -1848,3 +1848,28 @@ setMethod("crosstab", sct <- callJMethod(statFunctions, "crosstab", col1, col2) collect(dataFrame(sct)) }) + + +#' This function downloads the contents of a DataFrame into an R's data.frame. +#' Since data.frames are held in memory, ensure that you have enough memory +#' in your system to accommodate the contents. +#' +#' @title Download data from a DataFrame into a data.frame +#' @param x a DataFrame +#' @return a data.frame +#' @rdname as.data.frame +#' @examples \dontrun{ +#' +#' irisDF <- createDataFrame(sqlContext, iris) +#' df <- as.data.frame(irisDF[irisDF$Species == "setosa", ]) +#' } +setMethod("as.data.frame", + signature(x = "DataFrame"), + function(x, ...) { + # Check if additional parameters have been passed + if (length(list(...)) > 0) { + stop(paste("Unused argument(s): ", paste(list(...), collapse=", "))) + } + collect(x) + } +) |