From 5a40437e5c2a6dd4650f640c819819df3d1dbdac Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 23 Feb 2023 18:26:34 +0100 Subject: Basic check if covariate data are usable --- R/read_spreadsheet.R | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/R/read_spreadsheet.R b/R/read_spreadsheet.R index 7ad09c3e..1c5508da 100644 --- a/R/read_spreadsheet.R +++ b/R/read_spreadsheet.R @@ -101,13 +101,20 @@ read_spreadsheet <- function(path, valid_datasets = "all", # Get covariates covariates_raw <- readxl::read_excel(path, sheet = "Covariates") covariates <- as.data.frame(covariates_raw[4:ncol(covariates_raw)]) - rownames(covariates) <- covariates_raw[[1]] - covariates <- covariates[which(colnames(covariates) != "Remarks")] + nocov <- setdiff(groups, covariates_raw[[1]]) + if (length(nocov) > 0) { + message("Did not find covariate data for ", paste(nocov, collapse = ", ")) + message("Not returning covariate data") + attr(ds, "covariates") <- NULL + } else { + rownames(covariates) <- covariates_raw[[1]] + covariates <- covariates[which(colnames(covariates) != "Remarks")] + # Attach covariate data if available + attr(ds, "covariates") <- covariates[groups, , drop = FALSE] + } # Attach the compound list to support automatic model building attr(ds, "compounds") <- as.data.frame(compounds) - # Attach covariate data - attr(ds, "covariates") <- covariates[groups, , drop = FALSE] return(ds) } -- cgit v1.2.1