Sfoglia il codice sorgente

Fix column references

Bryan Roessler 7 mesi fa
parent
commit
4f9c2d3274
1 ha cambiato i file con 8 aggiunte e 8 eliminazioni
  1. 8 8
      qhtcp-workflow/apps/r/calculate_interaction_zscores.R

+ 8 - 8
qhtcp-workflow/apps/r/calculate_interaction_zscores.R

@@ -994,14 +994,14 @@ filter_data <- function(df, variables, nf = FALSE, missing = FALSE, adjust = FAL
   if (rank) {
     if (verbose) message("Calculating ranks for variable(s): ", paste(variables, collapse = ", "))
 
-    for (col in avg_zscore_cols) {
-      rank_col <- paste0("Rank_", col)
-      df[[rank_col]] <- rank(df[[col]], na.last = "keep")
-    }
-
-    for (col in z_lm_cols) {
-      rank_lm_col <- paste0("Rank_lm_", col)
-      df[[rank_lm_col]] <- rank(df[[col]], na.last = "keep")
+    for (variable in variables) {
+      avg_zscore_col <- paste0("Avg_Zscore_", variable)
+      rank_col <- paste0("Rank_", variable)
+      df[[rank_col]] <- rank(df[[avg_zscore_col]], na.last = "keep")
+
+      z_lm_col <- paste0("Z_lm_", variable)
+      rank_lm_col <- paste0("Rank_lm_", variable)
+      df[[rank_lm_col]] <- rank(df[[z_lm_col]], na.last = "keep")
     }
   }