@@ -119,19 +119,54 @@ ds.dataFrameSubset<-function(df.name=NULL, V1.name=NULL, V2.name=NULL, Boolean.o
119119 stop(" Please provide the name of the data.frame to be subsetted as a character string: eg 'xxx'" , call. = FALSE )
120120 }
121121
122- # check if user has provided the name of the column or scalar that holds V1
123- if (is.null(V1.name )){
124- stop(" Please provide the name of the column or scalar that holds V1 as a character string: eg 'xxx' or '3'" , call. = FALSE )
122+ # check if user has provided the name of the column or scalar that holds V1. If not
123+ # have they instead provided a non.null keep.cols or non.null rm.cols argument
124+ # in either of the latter cases then one needs to select all rows so
125+ # specify V1.name = "ONES" and this will specify a vector of 1s on the serverside
126+ # of length equal to dim[1] of the data.frame
127+
128+ if (is.null(keep.cols )&& is.null(rm.cols )&& is.null(V1.name ))
129+ {
130+ return (" Please provide the name of the column or scalar that holds V1 as a character string: eg 'xxx' or '3'" , call. = FALSE )
125131 }
126-
127- # check if user has provided the name of the column or scalar that holds V2
128- if (is.null(V2.name )){
129- stop(" Please provide the name of the column or scalar that holds V2 as a character string: eg 'xxx' or '3'" , call. = FALSE )
132+
133+ if ((! is.null(keep.cols )||! is.null(rm.cols ))&& is.null(V1.name ))
134+ {
135+ V1.name <- " ONES"
136+ }
137+
138+ # check if user has provided the name of the column or scalar that holds V2. If not
139+ # have they instead provided a non.null keep.cols or non.null rm.cols argument
140+ # in either of the latter cases then one needs to select all rows so
141+ # specify V2.name = "ONES" and this will specify a vector of 1s on the serverside
142+ # of length equal to dim[1] of the data.frame
143+
144+ if (is.null(keep.cols )&& is.null(rm.cols )&& is.null(V2.name ))
145+ {
146+ return (" Please provide the name of the column or scalar that holds V2 as a character string: eg 'xxx' or '3'" , call. = FALSE )
147+ }
148+
149+ if ((! is.null(keep.cols )||! is.null(rm.cols ))&& is.null(V2.name ))
150+ {
151+ V2.name <- " ONES"
130152 }
131153
132- # check if user has provided a Boolean operator in character format: eg '==' or '>=' or '<' or '!='
133- if (is.null(Boolean.operator )){
134- stop(" Please provide a Boolean operator in character format: eg '==' or '>=' or '<' or '!='" , call. = FALSE )
154+ if (is.null(keep.cols )&& is.null(rm.cols )&& is.null(Boolean.operator ))
155+ {
156+ message1 <- " Unless you are only subsetting columns, please provide a"
157+ message2 <- " Boolean operator in character format: eg '==' or '>=' or '<' or '!='."
158+ message3 <- " However, if either keep.cols or rm.cols is non-null because you want"
159+ message4 <- " to subset columns and you specify both V1.name and V2.name as NULL (or 'ONES')"
160+ message5 <- " and Boolean.operator as NULL,ds.dataFrameSubset will subset out"
161+ message6 <- " the specified columns but will keep all rows."
162+
163+ error.message <- paste(message1 ,message2 ,message3 ,message4 ,message5 ,message6 )
164+ return (error.message )
165+ }
166+
167+ if ((! is.null(keep.cols )||! is.null(rm.cols ))&& is.null(Boolean.operator ))
168+ {
169+ Boolean.operator <- " =="
135170 }
136171
137172 # if keep.NAs is set as NULL convert to FALSE as otherwise the call to datashield.assign will fail
0 commit comments