Skip to content

Commit 2ecd3b0

Browse files
committed
Merge branch 'v7.0-dev' of github.com:datashield/dsBase into refactor/perf-batch-9
2 parents 24f9939 + 7d281d0 commit 2ecd3b0

18 files changed

Lines changed: 120 additions & 81 deletions

‎R/rBinomDS.R‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
#' by <prob> argument of ds.rBinom - for details see help for ds.rBinom
1616
#' May be a scalar or a vector allowing the size to vary from
1717
#' observation to observation.
18-
#' @return Writes the pseudorandom number vector with the characteristics specified
19-
#' in the function call as a new serverside vector on the data source on which
20-
#' it has been called. Also returns key information to the clientside:
21-
#' the random seed as specified by you in each
22-
#' source + (if requested) the full 626 length random seed vector this generated in
23-
#' each source (see info for the argument <return.full.seed.as.set>). It
24-
#' also returns a vector reporting the length of the pseudorandom vector
25-
#' created in each source.
18+
#' @return the vector of pseudorandom numbers from a binomial distribution, which
19+
#' is written to the serverside as the object named by the <newobj> argument
20+
#' of ds.rBinom.
2621
#' @author Paul Burton for DataSHIELD Development Team
22+
#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands
2723
#' @export
2824
rBinomDS<-function (n, size = 1, prob = 0.5){
2925

@@ -34,13 +30,11 @@ rBinomDS<-function (n, size = 1, prob = 0.5){
3430
#first convert their names into the corresponding active vectors
3531

3632
if(is.character(size)){
37-
command.text<-size
38-
size<-eval(parse(text=command.text), envir = parent.frame())
33+
size<-.loadServersideObject(size)
3934
}
4035

4136
if(is.character(prob)){
42-
command.text<-prob
43-
prob<-eval(parse(text=command.text), envir = parent.frame())
37+
prob<-.loadServersideObject(prob)
4438
}
4539

4640
stats::rbinom(n, size=size, prob=prob)

‎R/rNormDS.R‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@
2020
#' have k decimal places. If k = 9, no rounding occurs of native output.
2121
#' Default=9. Value specified by <force.output.to.k.decimal.places> argument
2222
#' in ds.rNorm
23-
#' @return Writes the pseudorandom number vector with the characteristics specified
24-
#' in the function call as a new serverside vector on the data source on which
25-
#' it has been called. Also returns key information to the clientside:
26-
#' the random seed as specified by you in each
27-
#' source + (if requested) the full 626 length random seed vector this generated in
28-
#' each source (see info for the argument <return.full.seed.as.set>). It
29-
#' also returns a vector reporting the length of the pseudorandom vector
30-
#' created in each source.
23+
#' @return the numeric vector of pseudorandom numbers from a normal distribution,
24+
#' rounded to <force.output.to.k.decimal.places> decimal places if that is less
25+
#' than 9, which is written to the serverside as the object named by the <newobj>
26+
#' argument of ds.rNorm.
3127
#' @author Paul Burton for DataSHIELD Development Team
28+
#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands
3229
#' @export
3330
rNormDS<-function (n, mean = 0, sd = 1, force.output.to.k.decimal.places=9){
3431

@@ -39,13 +36,11 @@ rNormDS<-function (n, mean = 0, sd = 1, force.output.to.k.decimal.places=9){
3936
#first convert their names into the corresponding active vectors
4037

4138
if(is.character(mean)){
42-
command.text<-mean
43-
mean<-eval(parse(text=command.text), envir = parent.frame())
39+
mean<-.loadServersideObject(mean)
4440
}
4541

4642
if(is.character(sd)){
47-
command.text<-sd
48-
sd<-eval(parse(text=command.text), envir = parent.frame())
43+
sd<-.loadServersideObject(sd)
4944
}
5045

5146
random.number.vector<-stats::rnorm(n, mean=mean, sd=sd)

‎R/rPoisDS.R‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@
1111
#' distribution used to generate the random counts. Specified directly
1212
#' by the lambda argument in ds.rPois. May be a scalar or a vector allowing lambda
1313
#' to vary from observation to observation.
14-
#' @return Writes the pseudorandom number vector with the characteristics specified
15-
#' in the function call as a new serverside vector on the data source on which
16-
#' it has been called. Also returns key information to the clientside:
17-
#' the random seed as specified by you in each
18-
#' source + (if requested) the full 626 length random seed vector this generated in
19-
#' each source (see info for the argument <return.full.seed.as.set>). It
20-
#' also returns a vector reporting the length of the pseudorandom vector
21-
#' created in each source.
14+
#' @return the vector of pseudorandom non-negative integers from a Poisson
15+
#' distribution, which is written to the serverside as the object named by the
16+
#' <newobj> argument of ds.rPois.
2217
#' @author Paul Burton for DataSHIELD Development Team
18+
#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands
2319
#' @export
2420
rPoisDS<-function (n, lambda = 1){
2521

@@ -30,8 +26,7 @@ rPoisDS<-function (n, lambda = 1){
3026
#first convert its name into the corresponding active vectors
3127

3228
if(is.character(lambda)){
33-
command.text<-lambda
34-
lambda<-eval(parse(text=command.text), envir = parent.frame())
29+
lambda<-.loadServersideObject(lambda)
3530
}
3631

3732
stats::rpois(n, lambda=lambda)

‎R/rUnifDS.R‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@
2020
#' have k decimal places. If k = 9, no rounding occurs of native output.
2121
#' Default=9. Value specified by <force.output.to.k.decimal.places> argument
2222
#' in ds.rUnif
23-
#' @return Writes the pseudorandom number vector with the characteristics specified
24-
#' in the function call as a new serverside vector on the data source on which
25-
#' it has been called. Also returns key information to the clientside:
26-
#' the random seed as specified by you in each
27-
#' source + (if requested) the full 626 length random seed vector this generated in
28-
#' each source (see info for the argument <return.full.seed.as.set>). It
29-
#' also returns a vector reporting the length of the pseudorandom vector
30-
#' created in each source.
23+
#' @return the numeric vector of pseudorandom numbers from a uniform distribution,
24+
#' rounded to <force.output.to.k.decimal.places> decimal places if that is less
25+
#' than 9, which is written to the serverside as the object named by the <newobj>
26+
#' argument of ds.rUnif.
3127
#' @author Paul Burton for DataSHIELD Development Team
28+
#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands
3229
#' @export
3330
rUnifDS<-function (n, min = 0, max = 1, force.output.to.k.decimal.places=9){
3431

@@ -39,13 +36,11 @@ rUnifDS<-function (n, min = 0, max = 1, force.output.to.k.decimal.places=9){
3936
#first convert their names into the corresponding active vectors
4037

4138
if(is.character(min)){
42-
command.text<-min
43-
min<-eval(parse(text=command.text), envir = parent.frame())
39+
min<-.loadServersideObject(min)
4440
}
4541

4642
if(is.character(max)){
47-
command.text<-max
48-
max<-eval(parse(text=command.text), envir = parent.frame())
43+
max<-.loadServersideObject(max)
4944
}
5045

5146
random.number.vector<-stats::runif(n, min=min, max=max)

‎R/sampleDS.R‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#' 'newobj.sample') which is written to the serverside. For further details see
3131
#' help for ds.sample and native R help for sample().
3232
#' @author Paul Burton, for DataSHIELD Development Team, 15/4/2020
33+
#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands
3334
#' @export
3435
sampleDS <- function(x.transmit, size.transmit, replace.transmit=NULL, prob.transmit=NULL){
3536

@@ -82,7 +83,7 @@ sampleDS <- function(x.transmit, size.transmit, replace.transmit=NULL, prob.tran
8283
#Activate <x> and <prob> if they are character strings
8384
if(is.character(x.transmit))
8485
{
85-
x.active<-eval(parse(text=x.transmit), envir = parent.frame())
86+
x.active<-.loadServersideObject(x.transmit)
8687

8788
if(is.data.frame(x.active)||is.matrix(x.active))
8889
{
@@ -152,7 +153,7 @@ sampleDS <- function(x.transmit, size.transmit, replace.transmit=NULL, prob.tran
152153
prob.active<-NULL
153154
if(is.character(prob.transmit))
154155
{
155-
prob.active<-eval(parse(text=prob.transmit), envir = parent.frame())
156+
prob.active<-.loadServersideObject(prob.transmit)
156157
}
157158

158159
#Check size <= length(x.active) if replace.transmit==FALSE

‎R/setSeedDS.R‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,18 @@
3232
#' .Random.seed on each data source that is the true current state of the
3333
#' random seed in each source.
3434
#' @author Paul Burton for DataSHIELD Development Team
35+
#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands
3536
#' @export
3637
setSeedDS<-function (seedtext=NULL, kind = NULL, normal.kind = NULL)
3738
{
3839
# Check Permissive Privacy Control Level.
3940
dsBase::checkPermissivePrivacyControlLevel(c('permissive', 'avocado'))
4041

41-
seed<-eval(parse(text=seedtext), envir = parent.frame())
42+
if(is.null(seedtext) || seedtext == "NULL"){
43+
seed <- NULL
44+
} else {
45+
seed <- as.integer(seedtext)
46+
}
4247
set.seed(seed,kind,normal.kind)
4348
return(list(seed.as.set=.Random.seed))
4449
}

‎man/rBinomDS.Rd‎

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/rNormDS.Rd‎

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/rPoisDS.Rd‎

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎man/rUnifDS.Rd‎

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)