diff --git a/NAMESPACE b/NAMESPACE index cfeebe1..a681ae6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,6 +32,7 @@ exportMethods(formula) exportMethods(show) exportMethods(summary) exportMethods(update) +import(dplyr) import(jtools) import(methods) import(rlang) diff --git a/R/crosslag_utils.R b/R/crosslag_utils.R index 9875659..cb8fab9 100644 --- a/R/crosslag_utils.R +++ b/R/crosslag_utils.R @@ -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 @@ -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) } } @@ -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") } @@ -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") } @@ -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") } diff --git a/R/dpm.R b/R/dpm.R index 487298e..2c2b8ae 100644 --- a/R/dpm.R +++ b/R/dpm.R @@ -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) @@ -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) diff --git a/man/dpm-methods.Rd b/man/dpm-methods.Rd index 4a7d2ba..cb96b95 100644 --- a/man/dpm-methods.Rd +++ b/man/dpm-methods.Rd @@ -1,6 +1,5 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/dpm.R -\docType{methods} \name{update} \alias{update} \alias{update.dpm} diff --git a/man/dpm_tidiers.Rd b/man/dpm_tidiers.Rd index dc412cf..9d7efbc 100644 --- a/man/dpm_tidiers.Rd +++ b/man/dpm_tidiers.Rd @@ -5,9 +5,9 @@ \alias{glance.dpm} \title{Tidy methods for dpm} \usage{ -tidy.dpm(x, conf.int = FALSE, conf.level = 0.95, ...) +\method{tidy}{dpm}(x, conf.int = FALSE, conf.level = 0.95, ...) -glance.dpm(x, ...) +\method{glance}{dpm}(x, ...) } \arguments{ \item{x}{A \code{dpm} object.} @@ -16,7 +16,7 @@ glance.dpm(x, ...) interval in the tidy data frame.} \item{conf.level}{The confidence level to use for the confidence interval -when \code{conf.int} is TRUE. Default is .95, corresponding to a 95% confidence +when \code{conf.int} is TRUE. Default is .95, corresponding to a 95\% confidence interval.} \item{...}{Other arguments passed to \link[dpm]{summary.dpm}.} diff --git a/man/get_syntax.Rd b/man/get_syntax.Rd index 1bdb370..09b45ad 100644 --- a/man/get_syntax.Rd +++ b/man/get_syntax.Rd @@ -14,7 +14,7 @@ Default is TRUE.} } \description{ This helper function provides a simple way to retrieve the -lavaan model syntax from a fitted \code{\link[dpm:dpm]{dpm::dpm()}} object. +lavaan model syntax from a fitted \code{\link[=dpm]{dpm()}} object. } \examples{ diff --git a/man/get_wide_data.Rd b/man/get_wide_data.Rd index d44bc7a..006572f 100644 --- a/man/get_wide_data.Rd +++ b/man/get_wide_data.Rd @@ -11,7 +11,7 @@ get_wide_data(model) } \description{ This helper function provides a simple way to retrieve the -widened data from a fitted \code{\link[dpm:dpm]{dpm::dpm()}} object. +widened data from a fitted \code{\link[=dpm]{dpm()}} object. } \examples{ diff --git a/man/reexports.Rd b/man/reexports.Rd index c6cb953..f1d41a2 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -15,6 +15,6 @@ These objects are imported from other packages. Follow the links below to see their documentation. \describe{ - \item{panelr}{\code{\link[panelr]{panel_data}}, \code{\link[panelr]{long_panel}}, \code{\link[panelr]{widen_panel}}, \code{\link[panelr]{get_wave}}, \code{\link[panelr]{get_id}}} + \item{panelr}{\code{\link[panelr:get_wave]{get_id}}, \code{\link[panelr]{get_wave}}, \code{\link[panelr]{long_panel}}, \code{\link[panelr]{panel_data}}, \code{\link[panelr]{widen_panel}}} }} diff --git a/man/summary.dpm.Rd b/man/summary.dpm.Rd index c18a0d1..09a927a 100644 --- a/man/summary.dpm.Rd +++ b/man/summary.dpm.Rd @@ -1,14 +1,21 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/dpm.R -\docType{methods} \name{summary,dpm-method} \alias{summary,dpm-method} \title{Summarize dpm objects} \usage{ -\S4method{summary}{dpm}(object, standardized = FALSE, ci = FALSE, - se = TRUE, zstat = TRUE, pvalue = TRUE, ci.level = 0.95, +\S4method{summary}{dpm}( + object, + standardized = FALSE, + ci = FALSE, + se = TRUE, + zstat = TRUE, + pvalue = TRUE, + ci.level = 0.95, boot.ci.type = c("perc", "norm", "basic", "bca.simple"), - digits = getOption("dpm-digits", 3), ...) + digits = getOption("dpm-digits", 3), + ... +) } \arguments{ \item{object}{A \code{dpm} object.}