#------------------------------------------------------------------------------- # Copyright (c) 2018-2022 University of Newcastle upon Tyne. All rights reserved. # # This program and the accompanying materials # are made available under the terms of the GNU Public License v3.0. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . #------------------------------------------------------------------------------- # # Set up # connect.studies.dataset.cnsim(list("LAB_TSC", "LAB_TRIG")) # # Tests # context("ds.mean::disc::type=both") test_that("mean values [both]", { # myvectors <- c("D$LAB_TSC", "D$LAB_TRIG") # ds.dataFrame(x=myvectors, newobj="unsubset_df") # # ds.dataFrameSubset(df.name="unsubset_df", V1.name="D$LAB_TSC", V2.name="D$LAB_TRIG", Boolean.operator=">", newobj="subset_df") # # length_res <- ds.length("subset_df") # # expect_length(length_res, 4) # expect_equal(length_res$`length of subset_df in sim1`, 2) # expect_equal(length_res$`length of subset_df in sim2`, 2) # expect_equal(length_res$`length of subset_df in sim3`, 2) # expect_equal(length_res$`total length of subset_df in all studies combined`, 6) # # mean_res <- ds.mean(x="subset_df$LAB_TSC", type="both") # # expect_length(mean_res, 4) # expect_length(mean_res$Mean.by.Study, 12) # expect_true(is.na(mean_res$Mean.by.Study[1])) # expect_true(is.na(mean_res$Mean.by.Study[2])) # expect_true(is.na(mean_res$Mean.by.Study[3])) # expect_equal(as.integer(mean_res$Mean.by.Study[4]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[5]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[6]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[7]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[8]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[9]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[10]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[11]), 0) # expect_equal(as.integer(mean_res$Mean.by.Study[12]), 0) # expect_length(mean_res$Global.Mean, 4) # expect_true(is.na(mean_res$Global.Mean[1])) # expect_equal(as.integer(mean_res$Global.Mean[2]), 0) # expect_equal(as.integer(mean_res$Global.Mean[3]), 0) # expect_equal(as.integer(mean_res$Global.Mean[4]), 0) # expect_equal(mean_res$Nstudies, 3) # expect_length(mean_res$ValidityMessage, 3) # expect_equal(mean_res$ValidityMessage[1], "FAILED: Nvalid less than nfilter.tab") # expect_equal(mean_res$ValidityMessage[2], "FAILED: Nvalid less than nfilter.tab") # expect_equal(mean_res$ValidityMessage[3], "FAILED: Nvalid less than nfilter.tab") }) # # Done # disconnect.studies.dataset.cnsim()