From a5375d47e2454c929cbcdd99113229340c7e3191 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Wed, 13 Dec 2023 13:50:59 -0800 Subject: [PATCH] .get_phlabresults_data_from_NASIS_db: fix for #324 --- R/get_phlabresults_data_from_NASIS_db.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/get_phlabresults_data_from_NASIS_db.R b/R/get_phlabresults_data_from_NASIS_db.R index 53256dfb..d501c404 100644 --- a/R/get_phlabresults_data_from_NASIS_db.R +++ b/R/get_phlabresults_data_from_NASIS_db.R @@ -67,8 +67,8 @@ LEFT OUTER JOIN phlabresults_View_1 phl on phl.phiidref = ph.phiid d.dups_char <- do.call( "rbind", by(d.dups_char, d.dups_char[[var]], function(x) { data.frame( - peiid = unique(x[['peiid']]), - lapply(x[2:ncol(x)], function(x2) x2[which.max(x$hzthk)]) + peiid = unique(x[['peiid']]), + lapply(x[2:ncol(x)], function(x2) x2[max(c(1, which.max(x$hzthk)), na.rm = TRUE)]) )}) ) @@ -79,9 +79,9 @@ LEFT OUTER JOIN phlabresults_View_1 phl on phl.phiidref = ph.phiid d.dups_ph <- do.call( "rbind", by(d.dups_ph, d.dups_ph[[var]], function(x) { data.frame( - peiid = unique(x[['peiid']]), - phiid = unique(x[['phiid']]), - lapply(x[3:ncol(x)], function(x2) -log10(weighted.mean(1/10^x2, weights = x$hzthk, na.rm = TRUE))) + peiid = unique(x[['peiid']]), + phiid = unique(x[['phiid']]), + lapply(x[3:ncol(x)], function(x2) -log10(weighted.mean(1/10^x2, weights = x$hzthk, na.rm = TRUE))) )}) )