diff --git a/DESCRIPTION b/DESCRIPTION index fcb751a..c6716e5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: jstable Title: Create Tables from Different Types of Regression -Version: 1.1.0 -Date: 2023-05-04 +Version: 1.1.1 +Date: 2023-05-29 Authors@R: c(person("Jinseob", "Kim", email = "jinseob2kim@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9403-605X")), person("Zarathu", role = c("cph", "fnd")) ) diff --git a/NEWS.md b/NEWS.md index 9468d85..730ce5c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# jstable 1.1.1 + +* Bugfix `LabelepiDisplay`: thanks for `thisis05` + # jstable 1.1.0 * Bugfix `TableSubgroupCox`: thanks for `Ding-yuan Wan` diff --git a/R/label.R b/R/label.R index ded4a86..1ba2dae 100644 --- a/R/label.R +++ b/R/label.R @@ -72,7 +72,7 @@ mk.lev = function(data){ #' @importFrom data.table data.table := -LabelepiDisplay = function(epiDisplay.obj, label = F, ref){ +LabelepiDisplay <- function(epiDisplay.obj, label = F, ref){ lv2 <- variable <- level <- val_label <- NULL @@ -84,12 +84,12 @@ LabelepiDisplay = function(epiDisplay.obj, label = F, ref){ ## Var label - tb.rn = gsub(" \\(cont. var.\\)", "", rownames(tb.compact)) + tb.rn <- gsub(" \\(cont. var.\\)", "", rownames(tb.compact)) rownames(tb.compact) <- tb.rn if (nrow(tb.main) < 2 & label == T){ - vname <- strsplit(rownames(tb.compact)[1], ":")[[1]][1] - cond.lv2 <- grepl(":", rownames(tb.compact)[1]) & grepl("vs", rownames(tb.compact)[1]) + vname <- strsplit(rownames(tb.compact)[1], ": ")[[1]][1] + cond.lv2 <- grepl(": ", rownames(tb.compact)[1]) & grepl(" vs ", rownames(tb.compact)[1]) rownames(tb.compact) <- gsub(vname, ref[variable == vname, var_label][1], rownames(tb.compact)) if (cond.lv2){ lv2 <- strsplit(strsplit(rownames(tb.compact)[1], ": ")[[1]][[2]], " vs ")[[1]] @@ -103,8 +103,8 @@ LabelepiDisplay = function(epiDisplay.obj, label = F, ref){ vns <- c(vn, length(tb.rn)+1 ) vl <- lapply(1:length(vn), function(x){tb.rn[vns[x]:(vns[x+1]-1)]}) vl_label <- lapply(vl, function(x){ - vname <- strsplit(x[1], ":")[[1]][1] - cond.lv2 <- grepl(":", x[1]) & grepl("vs", x[1]) + vname <- strsplit(x[1], ": ")[[1]][1] + cond.lv2 <- grepl(": ", x[1]) & grepl(" vs ", x[1]) #x[1] <- gsub(vname, ref[variable == vname, var_label][1], x[1]) if (cond.lv2){ lv2 <- strsplit(strsplit(x[1], ": ")[[1]][[2]], " vs ")[[1]] @@ -165,7 +165,7 @@ LabelepiDisplay = function(epiDisplay.obj, label = F, ref){ #' @export #' @importFrom data.table data.table := -LabeljsTable = function(obj.table, ref){ +LabeljsTable <- function(obj.table, ref){ lv2 <- variable <- level <- val_label <- NULL @@ -177,8 +177,8 @@ LabeljsTable = function(obj.table, ref){ if (nrow(tb.main) == 1){ - vname <- strsplit(rownames(tb.compact)[1], ":")[[1]][1] - cond.lv2 <- grepl(":", rownames(tb.compact)[1]) & grepl("vs", rownames(tb.compact)[1]) + vname <- strsplit(rownames(tb.compact)[1], ": ")[[1]][1] + cond.lv2 <- grepl(":", rownames(tb.compact)[1]) & grepl(" vs ", rownames(tb.compact)[1]) rownames(tb.compact) <- gsub(vname, ref[variable == vname, var_label][1], rownames(tb.compact)) if (cond.lv2){ lv2 <- strsplit(strsplit(rownames(tb.compact)[1], ": ")[[1]][[2]], " vs ")[[1]] @@ -193,9 +193,9 @@ LabeljsTable = function(obj.table, ref){ vns <- c(vn, length(tb.rn)+1 ) vl <- lapply(1:length(vn), function(x){tb.rn[vns[x]:(vns[x+1]-1)]}) vl_label = lapply(vl, function(x){ - vname <- strsplit(x[1], ":")[[1]][1] + vname <- strsplit(x[1], ": ")[[1]][1] x[1] <- gsub(vname, ref[variable == vname, var_label][1], x[1]) - cond.lv2 <- grepl(":", x[1]) & grepl("vs", x[1]) + cond.lv2 <- grepl(": ", x[1]) & grepl(" vs ", x[1]) #x[1] <- gsub(vname, ref[variable == vname, var_label][1], x[1]) if (cond.lv2){ lv2 <- strsplit(strsplit(x[1], ": ")[[1]][[2]], " vs ")[[1]]