diff --git a/DESCRIPTION b/DESCRIPTION index 78f4dd7..ff55fdc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: Isinglandr Title: Landscape Construction and Simulation for Ising Networks -Version: 0.1.1 +Version: 0.1.1.9000 Authors@R: c( person("Jingmeng", "Cui", , "jingmeng.cui@outlook.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3421-8457")), @@ -46,4 +46,4 @@ Suggests: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.2 +RoxygenNote: 7.3.0 diff --git a/NEWS.md b/NEWS.md index 4b551e4..a3276f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# Development version + +- Bug-fix for `make_3d_Isingland()`: + - The function now allow character values for the `x` and `y` arguments. + # Isinglandr 0.1.1 - Bug-fix for the Shiny app (`shiny_Isingland_MDD()`): diff --git a/R/landscape.R b/R/landscape.R index c57a246..a9e8354 100644 --- a/R/landscape.R +++ b/R/landscape.R @@ -190,7 +190,8 @@ plot.2d_Isingland_matrix <- function(x, ...) { #' #' @inheritParams make_2d_Isingland #' @param x,y Two vectors specifying the indices or the names of the -#' nodes for two categories. +#' nodes for two categories. If they are character vectors, the names +#' should match the row names of the `thresholds` matrix. #' #' @seealso [make_2d_Isingland()] for the algorithm. #' @@ -207,6 +208,15 @@ make_3d_Isingland <- function(thresholds, weiadj, x, y, beta = 1, transform = FA l_2d <- make_2d_Isingland(thresholds, weiadj, beta, transform) d <- l_2d$dist_raw + if (is.character(x)) { + if (!all(x %in% row.names(thresholds))) stop("The names in x are not found in the row names of the thresholds matrix.") + x <- which(row.names(thresholds) %in% x) + } + if (is.character(y)) { + if (!all(y %in% row.names(thresholds))) stop("The names in y are not found in the row names of the thresholds matrix.") + y <- which(row.names(thresholds) %in% y) + } + ## summarize based on the number of symptoms in the groups x & y d_sum <- d %>% dplyr::rowwise() %>% diff --git a/man/make_3d_Isingland.Rd b/man/make_3d_Isingland.Rd index ecb6e2e..42bf939 100644 --- a/man/make_3d_Isingland.Rd +++ b/man/make_3d_Isingland.Rd @@ -13,7 +13,8 @@ of the Ising network. If you have an \code{IsingFit} object estimated using (\verb{$thresholds} and \verb{$weiadj}).} \item{x, y}{Two vectors specifying the indices or the names of the -nodes for two categories.} +nodes for two categories. If they are character vectors, the names +should match the row names of the \code{thresholds} matrix.} \item{beta}{The \eqn{\beta} value for calculating the Hamiltonian.}