From aeca86ef9d4cf4e00aaa1e03b45ecce64a77eab3 Mon Sep 17 00:00:00 2001 From: Toby Dylan Hocking Date: Wed, 10 Apr 2024 22:13:52 -0700 Subject: [PATCH] unlist varsYZ --- vardpoor/R/vardcros.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vardpoor/R/vardcros.R b/vardpoor/R/vardcros.R index 2673b2c..3a1c91b 100644 --- a/vardpoor/R/vardcros.R +++ b/vardpoor/R/vardcros.R @@ -625,10 +625,10 @@ vardcros <- function(Y, H, PSU, w_final, varsYZ <- list(namesY) if (!is.null(namesZ)) varsYZ <- list(namesY, namesZ) + if (length(varsYZ)==1) varsYZ <- unlist(varsYZ) DTagg <- melt(DTagg, id = c(namesperc, gnamesDom), measure = varsYZ, variable.factor = FALSE) - setnames(DTagg, ifelse(!is.null(DTagg$value1), "value1", "value"), "totalY") totYZ <- "totalY" if (!is.null(Z)) {totYZ <- c(totYZ, "totalZ") @@ -731,7 +731,7 @@ vardcros <- function(Y, H, PSU, w_final, keyby = namesperc, .SDcols = namesY2] varsYZ <- list(namesY1) if (!is.null(namesZ1) & !linratio) varsYZ <- list(namesY1, namesZ1) - + if (length(varsYZ)==1) varsYZ <- unlist(varsYZ) DT2 <- melt(DT2, id = namesperc, measure = varsYZ, variable.factor = FALSE)