From 73ffc8d2d989f82f880ea93648e44de68bca1e68 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Mon, 28 Sep 2026 16:00:12 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20surveyFA.R=20=EA=B3=A0?= =?UTF-8?q?=EC=9C=A0=EA=B0=92=20=ED=8C=90=EB=B3=84=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=B0=8F=20as.data.frame=20=EA=B0=95=EC=A0=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EB=B3=91=EB=AA=A9=20=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/surveyFA.R | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/R/surveyFA.R b/R/surveyFA.R index f60fffd8..2e366dad 100644 --- a/R/surveyFA.R +++ b/R/surveyFA.R @@ -80,12 +80,19 @@ surveyFA <- function( stop("surveyFA requires pThreshold to be in (0, 1].", call. = FALSE) } - response_data <- as.data.frame(data) - response_data <- - response_data[, vapply(response_data, function(column) { - nunique <- length(unique(stats::na.omit(column))) - nunique >= 2L - }, logical(1L))] + if (is.matrix(data)) { + response_data <- data[, apply(data, 2, function(column) { + c_no_na <- column[!is.na(column)] + if (length(c_no_na) == 0L) FALSE else any(c_no_na != c_no_na[1L]) + }), drop = FALSE] + response_data <- as.data.frame(response_data) + } else { + response_data <- as.data.frame(data) + response_data <- response_data[, vapply(response_data, function(column) { + c_no_na <- column[!is.na(column)] + if (length(c_no_na) == 0L) FALSE else any(c_no_na != c_no_na[1L]) + }, logical(1L)), drop = FALSE] + } if (nrow(response_data) == 0L || ncol(response_data) < 2L) { stop("surveyFA needs at least two non-constant response columns.", call. = FALSE)