Skip to content

Commit 4d0edb5

Browse files
committed
alternate fix for CRAN check
1 parent 58b7677 commit 4d0edb5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

R/pkg/NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Imports from base R
2+
# Do not include stats:: "rpois", "runif" - causes error at runtime
23
importFrom("methods", "setGeneric", "setMethod", "setOldClass")
34
importFrom("methods", "is", "new", "signature", "show")
4-
importFrom("stats", "gaussian", "rpois", "runif", "setNames")
5+
importFrom("stats", "gaussian", "setNames")
56
importFrom("utils", "download.file", "packageVersion", "untar")
67

78
# Disable native libraries till we figure out how to package it

R/pkg/R/RDD.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,17 +887,17 @@ setMethod("sampleRDD",
887887

888888
# Discards some random values to ensure each partition has a
889889
# different random seed.
890-
runif(partIndex)
890+
stats::runif(partIndex)
891891

892892
for (elem in part) {
893893
if (withReplacement) {
894-
count <- rpois(1, fraction)
894+
count <- stats::rpois(1, fraction)
895895
if (count > 0) {
896896
res[ (len + 1) : (len + count) ] <- rep(list(elem), count)
897897
len <- len + count
898898
}
899899
} else {
900-
if (runif(1) < fraction) {
900+
if (stats::runif(1) < fraction) {
901901
len <- len + 1
902902
res[[len]] <- elem
903903
}
@@ -965,15 +965,15 @@ setMethod("takeSample", signature(x = "RDD", withReplacement = "logical",
965965

966966
set.seed(seed)
967967
samples <- collectRDD(sampleRDD(x, withReplacement, fraction,
968-
as.integer(ceiling(runif(1,
968+
as.integer(ceiling(stats::runif(1,
969969
-MAXINT,
970970
MAXINT)))))
971971
# If the first sample didn't turn out large enough, keep trying to
972972
# take samples; this shouldn't happen often because we use a big
973973
# multiplier for thei initial size
974974
while (length(samples) < total)
975975
samples <- collectRDD(sampleRDD(x, withReplacement, fraction,
976-
as.integer(ceiling(runif(1,
976+
as.integer(ceiling(stats::runif(1,
977977
-MAXINT,
978978
MAXINT)))))
979979

R/pkg/R/pairRDD.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,19 +917,19 @@ setMethod("sampleByKey",
917917
len <- 0
918918

919919
# mixing because the initial seeds are close to each other
920-
runif(10)
920+
stats::runif(10)
921921

922922
for (elem in part) {
923923
if (elem[[1]] %in% names(fractions)) {
924924
frac <- as.numeric(fractions[which(elem[[1]] == names(fractions))])
925925
if (withReplacement) {
926-
count <- rpois(1, frac)
926+
count <- stats::rpois(1, frac)
927927
if (count > 0) {
928928
res[ (len + 1) : (len + count) ] <- rep(list(elem), count)
929929
len <- len + count
930930
}
931931
} else {
932-
if (runif(1) < frac) {
932+
if (stats::runif(1) < frac) {
933933
len <- len + 1
934934
res[[len]] <- elem
935935
}

0 commit comments

Comments
 (0)