Skip to content

Commit

Permalink
Linting and re-documenting
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-long committed Jan 11, 2024
1 parent 8b773d6 commit 642a676
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exportMethods(formula)
exportMethods(show)
exportMethods(summary)
exportMethods(update)
import(dplyr)
import(jtools)
import(methods)
import(rlang)
Expand Down
9 changes: 5 additions & 4 deletions R/crosslag_utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' @importFrom stats terms
#' @import stringr
#' @import dplyr
#' @importFrom panelr are_varying
formula_parser <- function(formula, dv, data) {
# See how many parts the formula has
Expand Down Expand Up @@ -138,7 +139,7 @@ formula_parser <- function(formula, dv, data) {
the_call <-
match.call(dplyr::lag, call = parse(text = v_info$term[i]))
v_info$lag[i] <- if (!is.null(the_call$n)) the_call$n else 1
v_info$root[i] <- as.character(the_call$x)
v_info$root[i] <- to_char(the_call$x)
}
}

Expand All @@ -165,7 +166,7 @@ formula_parser <- function(formula, dv, data) {
if (length(wint_labs) > 0) {
for (wint in wint_labs) {
endog <- str_detect(wint, "(?<=pre\\().*(?=\\))")
while (stringr::str_detect(wint, "(?<=pre\\().*(?=\\))")) {
while(stringr::str_detect(wint, "(?<=pre\\().*(?=\\))")) {
wint <- str_replace(wint, "(.*)(pre\\()(.*)(\\))(.*)", "\\1\\3\\5")
}

Expand All @@ -185,7 +186,7 @@ formula_parser <- function(formula, dv, data) {
v_info[my_row, "max_lag"] <- max(lags)
}
}
while (stringr::str_detect(wint_labs, "(?<=pre\\().*(?=\\))")) {
while (any(stringr::str_detect(wint_labs, "(?<=pre\\().*(?=\\))"))) {
wint_labs <- str_replace(wint_labs, "(.*)(pre\\()(.*)(\\))(.*)",
"\\1\\3\\5")
}
Expand Down Expand Up @@ -215,7 +216,7 @@ formula_parser <- function(formula, dv, data) {
v_info[my_row, "max_lag"] <- max(lags)
}
}
while (stringr::str_detect(cint_labs, "(?<=pre\\().*(?=\\))")) {
while (any(stringr::str_detect(cint_labs, "(?<=pre\\().*(?=\\))"))) {
cint_labs <- str_replace(cint_labs, "(.*)(pre\\()(.*)(\\))(.*)",
"\\1\\3\\5")
}
Expand Down
6 changes: 3 additions & 3 deletions R/dpm.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ dpm <- function(formula, data, error.inv = FALSE, const.inv = FALSE,
stop_wrap("data argument must be a data frame.")
}

id <- as_name(enexpr(id))
wave <- as_name(enexpr(wave))
id <- as_name(enquo(id))
wave <- as_name(enquo(wave))
data <- panelr::panel_data(data, !! sym(id), !! sym(wave))
} else {
wave <- panelr::get_wave(data)
Expand All @@ -167,7 +167,7 @@ dpm <- function(formula, data, error.inv = FALSE, const.inv = FALSE,
pf <- formula_parser(formula, dv, data)

# Need to add interaction variables to data frame before calling model_frame
if (length(pf$wint_labs) > 0 | length(pf$cint_labs) > 0 |
if (length(pf$wint_labs) > 0 || length(pf$cint_labs) > 0 ||
length(pf$bint_labs) > 0) {
for (int in c(pf$wint_labs, pf$cint_labs, pf$bint_labs)) {
new_name <- make_names(int, TRUE)
Expand Down
1 change: 0 additions & 1 deletion man/dpm-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/dpm_tidiers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/get_syntax.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/get_wide_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/reexports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions man/summary.dpm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 642a676

Please sign in to comment.