#-------------------------------------- HEADER --------------------------------------------#
#' @title Missing Values of Study Variable
#' @description Computes the missing values of a given study variable.
#' Count all values set as NA or another missing value indicator.
#' @details It is a wrapper for the server side function \code{\link{getNumNa}}.
#' @param x a character, the name of study variable.
#' @param datasources a list of opal object(s) obtained after login in to opal servers;
#' these objects hold also the data assign to R, as \code{data frame}, from opal datasources.
#' @return return a numeric value.
#' @author Paula Raissa Costa e Silva
#' @section Dependencies:
#' \code{\link{getNumNa}}
#' @export
#' @examples {
#' na <- ds.na('D$birth_weight')
#' }
#'
ds.na <- function(x=NULL, datasources=NULL) {
if(is.null(x)){
stop("Please provide the name of the input vector", call. = FALSE)
}
# if no opal login details are provided look for 'opal' objects in the environment
if(is.null(datasources)){
datasources <- findLoginObjects()
}
xnames <- extract(x)
varname <- xnames$elements
obj2lookfor <- xnames$holders
if(is.na(obj2lookfor)){
defined <- isDefined(datasources, varname)
} else {
defined <- isDefined(datasources, obj2lookfor)
}
# typ <- checkClass(datasources, x)
# if(typ!='integer' & typ!='numeric'){
# message(paste0(x, "is of type ", typ, "!"))
# stop("The input vector must be integer or numeric vector", call. = FALSE)
# }
#number of studies
num.sources <- length(datasources)
result <- list()
for (i in 1:num.sources) {
cally <- call("getNumNa", x)
result <- opal::datashield.aggregate(datasources, cally)
}
return(result)
# total.na <- 0
# for(node in result) {
# total.na <- total.na + node
# }
#
# return(total.na)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.