Skip to content

Commit

Permalink
fix #34
Browse files Browse the repository at this point in the history
  • Loading branch information
piccolbo committed Nov 21, 2014
1 parent 3b8a494 commit b2ca8dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
10 changes: 4 additions & 6 deletions R/package/R/ddf.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,11 @@ setMethod("as.data.frame",
#' @param x a DistributedDataFrame
#' @param size number of samples
#' @param replace sampling with or without replacement
#' @param seed a random seed
#' @export
setMethod("sample",
signature("DDF"),
function(x, size, replace=FALSE, seed=123L) {
res <- x@jddf$VIEWS$getRandomSample(as.integer(size), replace, seed)
function(x, size, replace=FALSE) {
res <- x@jddf$VIEWS$getRandomSample(as.integer(size), replace, sample.int(.Machine$integer.max, 1))
ncols <- ncol(x)
parsed.res <- t(sapply(res,
function(x) {sapply(1:ncols, function(y){.jarray(x)[[y]]$toString()})}))
Expand All @@ -195,7 +194,6 @@ setMethod("sample",
#' @param x a DistributedDataFrame
#' @param percent a double value specify the fraction
#' @param replace sampling with or without replacement
#' @param seed a random seed
#' @return a DistributedDataFrame
#' @export
setGeneric("sample2ddf",
Expand All @@ -206,8 +204,8 @@ setGeneric("sample2ddf",

setMethod("sample2ddf",
signature("DDF"),
function(x, percent, replace=FALSE, seed=123L) {
new ("DDF",x@jddf$VIEWS$getRandomSample(percent, replace, seed))
function(x, percent, replace=FALSE) {
new ("DDF",x@jddf$VIEWS$getRandomSample(percent, replace, sample.int(.Machine$integer.max, 1)))
}
)

Expand Down
4 changes: 1 addition & 3 deletions R/package/man/sample-DDF-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
\alias{sample,DDF-method}
\title{Return a sample of specific size from a DistributedDataFrame}
\usage{
\S4method{sample}{DDF}(x, size, replace = FALSE, seed = 123L)
\S4method{sample}{DDF}(x, size, replace = FALSE)
}
\arguments{
\item{x}{a DistributedDataFrame}

\item{size}{number of samples}

\item{replace}{sampling with or without replacement}

\item{seed}{a random seed}
}
\description{
Return a sample of specific size from a DistributedDataFrame
Expand Down
2 changes: 0 additions & 2 deletions R/package/man/sample2ddf.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ sample2ddf(x, ...)
\item{percent}{a double value specify the fraction}

\item{replace}{sampling with or without replacement}

\item{seed}{a random seed}
}
\value{
a DistributedDataFrame
Expand Down

0 comments on commit b2ca8dc

Please sign in to comment.