Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ropensci/dynamite
Browse files Browse the repository at this point in the history
  • Loading branch information
helske committed Apr 23, 2024
2 parents 78530e6 + 69ad700 commit 47483ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
25 changes: 20 additions & 5 deletions R/dynamiteformula.R
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,26 @@ parse_formula <- function(x, family) {
formula_parts
)
formulas <- lapply(paste0(responses, "~", formula_parts), as.formula)
predictors <- ulapply(formulas, function(y) {
find_nonlags(formula_rhs(y))
})
resp_pred <- responses %in% predictors
predictors <- lapply(
formulas,
function(y) {
find_nonlags(formula_rhs(y))
}
)
resp_pred <- vapply(
seq_along(responses),
function(i) {
responses[i] %in% predictors[[i]]
},
logical(1L)
)
# predictors <- ulapply(
# formulas,
# function(y) {
# find_nonlags(formula_rhs(y))
# }
# )
# resp_pred <- responses %in% predictors
p <- sum(resp_pred)
stopifnot_(
!any(resp_pred),
Expand Down Expand Up @@ -353,7 +369,6 @@ parse_name <- function(x) {
gsub("[^[:alnum:]_]+", "", x, perl = TRUE)
}


#' @rdname dynamiteformula
#' @param e1 \[`dynamiteformula`]\cr A model formula specification.
#' @param e2 \[`dynamiteformula`]\cr A model formula specification.
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ test_that("contemporaneous self dependency within a channel fails", {
)
)
expect_error(
obs(c(y, x) ~ x | 1, family = "mvgaussian"),
obs(c(y, x) ~ y | 1, family = "mvgaussian"),
paste0(
"Contemporaneous self-dependency found in model formula:\n",
"x Variable `x` appears on both sides of the formula for \\(y, x\\)\\."
"x Variable `y` appears on both sides of the formula for \\(y, x\\)\\."
)
)
})
Expand Down

0 comments on commit 47483ea

Please sign in to comment.