Skip to content

Commit f7a96cb

Browse files
Merge branch 'v6.4.0-dev' into v6.4.0-dev-feat/as-data-frame
2 parents bf169db + 9198bb3 commit f7a96cb

58 files changed

Lines changed: 1406 additions & 1496 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
^data$
88
^docs$
99
^pkgdown$
10+
^\.circleci$
11+
^\.circleci/config\.yml$

.circleci/config.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 2024 Arjuna Technologies, Newcastle upon Tyne. All rights reserved.
2+
3+
version: 2.1
4+
5+
jobs:
6+
dsbase:
7+
docker:
8+
- image: cimg/base:current
9+
resource_class: small
10+
steps:
11+
- checkout
12+
- setup_remote_docker:
13+
docker_layout_caching: true
14+
- run: |
15+
echo "Building"
16+
echo " Repo Name: " $CIRCLE_PROJECT_REPONAME
17+
echo " Branch: " $CIRCLE_BRANCH
18+
echo " Tag: " $CIRCLE_TAG
19+
- run:
20+
command: |
21+
sudo apt-get update -y
22+
sudo apt-get install -y r-base-core cmake
23+
- run:
24+
command: |
25+
sudo apt-get install -y libxml2-dev
26+
- run:
27+
command: |
28+
sudo Rscript -e "install.packages('RANN', dependencies=TRUE)"
29+
sudo Rscript -e "install.packages('stringr', dependencies=TRUE)"
30+
sudo Rscript -e "install.packages('lme4', dependencies=TRUE)"
31+
sudo Rscript -e "install.packages('dplyr', dependencies=TRUE)"
32+
sudo Rscript -e "install.packages('reshape2', dependencies=TRUE)"
33+
sudo Rscript -e "install.packages('polycor', dependencies=TRUE)"
34+
sudo Rscript -e "install.packages('splines', dependencies=TRUE)"
35+
sudo Rscript -e "install.packages('gamlss', dependencies=TRUE)"
36+
sudo Rscript -e "install.packages('gamlss.dist', dependencies=TRUE)"
37+
sudo Rscript -e "install.packages('mice', dependencies=TRUE)"
38+
sudo Rscript -e "install.packages('childsds', dependencies=TRUE)"
39+
sudo Rscript -e "install.packages('xml2', dependencies=TRUE)"
40+
sudo Rscript -e "install.packages('covr', dependencies=TRUE)"
41+
sudo Rscript -e "install.packages('devtools', dependencies=TRUE)"
42+
sudo Rscript -e "install.packages('DSI', dependencies=TRUE)"
43+
sudo Rscript -e "install.packages('DSLite', dependencies=TRUE)"
44+
- run:
45+
command: |
46+
sudo Rscript -e 'library(covr); covr::codecov(token = "'$CODECOV_TOKEN'")'
47+
workflows:
48+
build:
49+
jobs:
50+
- dsbase

DESCRIPTION

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Package: dsBase
2-
Title: DataSHIELD server site base functions
3-
Description: DataSHIELD server site base functions.
2+
Title: DataSHIELD Server Site Base Functions
3+
Description: DataSHIELD Server Site Base Functions.
44
Version: 6.4.0.9000
55
Author: DataSHIELD Developers <datashield@liverpool.ac.uk>
66
Maintainer: DataSHIELD Developers <datashield@liverpool.ac.uk>
77
License: GPL-3
88
Depends:
9-
R (>= 3.5.0)
9+
R (>= 4.0.0)
1010
Imports:
1111
RANN,
1212
stringr,
@@ -18,7 +18,10 @@ Imports:
1818
gamlss,
1919
gamlss.dist,
2020
mice,
21-
childsds
21+
childsds,
22+
purrr,
23+
tibble,
24+
tidyverse
2225
Suggests:
2326
testthat
2427
AggregateMethods:
@@ -158,8 +161,6 @@ AssignMethods:
158161
sampleDS,
159162
seqDS,
160163
sqrtDS,
161-
subsetByClassDS,
162-
subsetDS,
163164
tableDS.assign,
164165
tapplyDS.assign,
165166
uniqueDS,

NAMESPACE

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ export(dmtC2SDS)
4242
export(elsplineDS)
4343
export(extractQuantilesDS1)
4444
export(extractQuantilesDS2)
45+
export(fixClassDS)
46+
export(fixColsDS)
47+
export(fixLevelsDS)
4548
export(gamlssDS)
49+
export(getAllLevelsDS)
50+
export(getClassAllColsDS)
4651
export(getWGSRDS)
4752
export(glmDS1)
4853
export(glmDS2)
@@ -120,8 +125,6 @@ export(setSeedDS)
120125
export(skewnessDS1)
121126
export(skewnessDS2)
122127
export(sqrtDS)
123-
export(subsetByClassDS)
124-
export(subsetDS)
125128
export(table1DDS)
126129
export(table2DDS)
127130
export(tableDS)
@@ -139,5 +142,14 @@ import(dplyr)
139142
import(gamlss)
140143
import(gamlss.dist)
141144
import(mice)
145+
importFrom(dplyr,"%>%")
146+
importFrom(dplyr,across)
147+
importFrom(dplyr,mutate)
148+
importFrom(dplyr,select)
142149
importFrom(gamlss.dist,pST3)
143150
importFrom(gamlss.dist,qST3)
151+
importFrom(purrr,map)
152+
importFrom(purrr,set_names)
153+
importFrom(tibble,as_tibble)
154+
importFrom(tidyselect,all_of)
155+
importFrom(tidyselect,peek_vars)

R/asCharacterDS.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
asCharacterDS <- function (x.name){
1616

17-
x<-eval(parse(text=x.name), envir = parent.frame())
17+
x <- eval(parse(text=x.name), envir = parent.frame())
1818

1919
output <- as.character(x)
2020
return(output)

R/asDataMatrixDS.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
asDataFrameDS <- function (x.name){
1515

1616
if(is.character(x.name)){
17-
x<-eval(parse(text=x.name), envir = parent.frame())
17+
x <- eval(parse(text=x.name), envir = parent.frame())
1818

1919
}else{
2020
studysideMessage<-"ERROR: x.name must be specified as a character string"
2121
stop(studysideMessage, call. = FALSE)
22-
}
22+
}
2323

2424
output <- data.frame(x)
2525

R/asFactorDS1.R

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#' @export
1111
#'
1212
asFactorDS1 <- function(input.var.name=NULL){
13+
1314
##################################################################
1415
#MODULE 1: CAPTURE THE nfilter SETTINGS #
1516
thr<-dsBase::listDisclosureSettingsDS() #
@@ -26,27 +27,29 @@ asFactorDS1 <- function(input.var.name=NULL){
2627

2728
input.var <- eval(parse(text=input.var.name), envir = parent.frame())
2829
factor.levels.present.in.source <- levels(factor(input.var))
29-
num.levels<-length(factor.levels.present.in.source)
30+
num.levels <- length(factor.levels.present.in.source)
3031

3132
max.levels.by.density<-nfilter.levels.density*length(input.var)
3233

33-
if(num.levels>nfilter.levels.max)
34-
{
35-
error.message<-
36-
paste0("FAILED: this variable has too many levels and may be disclosive. It exceeds the max number of levels allowed by nfilter.levels.max: that is ",nfilter.levels.max,". In this study this variable has ",num.levels," factor levels")
34+
if(num.levels > nfilter.levels.max){
35+
error.message <- paste0("FAILED: this variable has too many levels and may be disclosive.
36+
It exceeds the max number of levels allowed by nfilter.levels.max:
37+
that is ", nfilter.levels.max, ". In this study this variable has ",
38+
num.levels," factor levels")
3739
stop(error.message, call. = FALSE)
3840
}
3941

40-
if(num.levels>(length(input.var)*nfilter.levels.density))
41-
{
42-
error.message<-
43-
paste0("FAILED: this variable has too many levels and may be disclosive. The number of factor levels must not exceed ", (nfilter.levels.density*100), "% of the length of the variable being converted to a factor. The max number of levels in this study is therefore ",max.levels.by.density," but this variable has ",num.levels," factor levels")
42+
if(num.levels > (length(input.var)*nfilter.levels.density)){
43+
error.message <- paste0("FAILED: this variable has too many levels and may be disclosive.
44+
The number of factor levels must not exceed ", (nfilter.levels.density*100),
45+
"% of the length of the variable being converted to a factor. The max number
46+
of levels in this study is therefore ",max.levels.by.density," but this
47+
variable has ", num.levels, " factor levels")
4448
stop(error.message, call. = FALSE)
4549
}
4650

4751
return(factor.levels.present.in.source)
4852

4953
}
50-
#AGGREGATE FUNCTION
54+
# AGGREGATE FUNCTION
5155
# asFactorDS1
52-

R/asListDS.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#'
12
#' @title asListDS a serverside aggregate function called by ds.asList
23
#' @description Coerces an R object into a list
34
#' @details Unlike most other class coercing functions this is
@@ -21,25 +22,26 @@
2122
#' the class of the output object should usually be 'list'
2223
#' @author Amadou Gaye, Paul Burton for DataSHIELD Development Team
2324
#' @export
25+
#'
2426
asListDS <- function (x.name, newobj){
2527

2628
newobj.class <- NULL
2729
if(is.character(x.name)){
28-
active.text<-paste0(newobj,"<-as.list(",x.name,")")
30+
active.text <- paste0(newobj,"<-as.list(",x.name,")")
2931
eval(parse(text=active.text), envir = parent.frame())
3032

31-
active.text2<-paste0("class(",newobj,")")
33+
active.text2 <- paste0("class(",newobj,")")
3234
assign("newobj.class", eval(parse(text=active.text2), envir = parent.frame()))
3335

3436
}else{
35-
studysideMessage<-"ERROR: x.name must be specified as a character string"
37+
studysideMessage <- "ERROR: x.name must be specified as a character string"
3638
stop(studysideMessage, call. = FALSE)
3739
}
3840

39-
return.message<-paste0("New object <",newobj,"> created")
40-
object.class.text<-paste0("Class of <",newobj,"> is '",newobj.class,"'")
41+
return.message <- paste0("New object <", newobj, "> created")
42+
object.class.text <- paste0("Class of <", newobj, "> is '", newobj.class, "'")
4143

42-
return(list(return.message=return.message,class.of.newobj=object.class.text))
44+
return(list(return.message=return.message, class.of.newobj=object.class.text))
4345
}
4446
# AGGEGATE FUNCTION
4547
# asListDS

R/asLogicalDS.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#'
12
#' @title Coerces an R object into class numeric
23
#' @description this function is based on the native R function \code{as.numeric}
34
#' @details See help for function \code{as.logical} in native R
@@ -10,24 +11,25 @@
1011
#' details see help on the clientside function \code{ds.asLogical}
1112
#' @author Amadou Gaye, Paul Burton for DataSHIELD Development Team
1213
#' @export
14+
#'
1315
asLogicalDS <- function (x.name){
1416

15-
if(is.character(x.name)){
16-
x<-eval(parse(text=x.name), envir = parent.frame())
17+
if(is.character(x.name)){
18+
x <- eval(parse(text=x.name), envir = parent.frame())
1719

1820
}else{
19-
studysideMessage<-"ERROR: x.name must be specified as a character string"
21+
studysideMessage <- "ERROR: x.name must be specified as a character string"
2022
stop(studysideMessage, call. = FALSE)
21-
}
23+
}
2224

23-
if(!is.numeric(x)&&!is.integer(x)&&!is.character(x)&&!is.matrix(x)){
24-
studysideMessage<-"ERROR: for ds.asLogical function, x.name must specify an input object of class numeric, integer, character or matrix"
25-
stop(studysideMessage, call. = FALSE)
25+
if(!is.numeric(x) && !is.integer(x) && !is.character(x) && !is.matrix(x)){
26+
studysideMessage <- "ERROR: for ds.asLogical function, x.name must specify an input object of class numeric, integer, character or matrix"
27+
stop(studysideMessage, call. = FALSE)
2628
}
2729

2830
output <- as.logical(x)
2931

3032
return(output)
3133
}
32-
#ASSIGN FUNCTION
34+
# ASSIGN FUNCTION
3335
# asLogicalDS

R/aucDS.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ aucDS <- function(pred=pred, y=y){
3131
q2 <- 2*AUC^2/(1+AUC)-AUC^2
3232
se <- sqrt((q0+(n0-1)*q1+(n1-1)*q2)/(n0*n1))
3333

34-
return(list(AUC=AUC,se=se))
34+
return(list(AUC=AUC, se=se))
3535

3636
}

0 commit comments

Comments
 (0)