Skip to content

Commit

Permalink
minor change, remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu committed Jun 21, 2023
1 parent 0e68a92 commit 0e459da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/cox_regression_inter.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' of the covariate, in comparison to the treatment control.
#'
#' @inheritParams argument_convention
#' @param x (`numeric` or `factor`)\cr the values of the effect to be tested.
#' @param x (`numeric` or `factor`)\cr the values of the covariate to be tested.
#' @param effect (`string`)\cr the name of the effect to be tested and estimated.
#' @param covar (`string`)\cr the name of the covariate in the model.
#' @param mod (`coxph`)\cr the Cox regression model.
Expand Down Expand Up @@ -135,19 +135,20 @@ h_coxreg_inter_effect.factor <- function(x,
control,
data,
...) {
lvl_given = levels(x)
y <- h_coxreg_inter_estimations(
variable = effect, given = covar,
lvl_var = levels(data[[effect]]),
lvl_given = levels(data[[covar]]),
lvl_given = lvl_given,
mod = mod,
conf_level = 0.95
)[[1]]

data.frame(
effect = "Covariate:",
term = rep(covar, nrow(y)),
term_label = as.character(paste0(" ", levels(data[[covar]]))),
level = as.character(levels(data[[covar]])),
term_label = as.character(paste0(" ", lvl_given)),
level = as.character(lvl_given),
n = NA,
hr = y[, "hr"],
lcl = y[, "lcl"],
Expand Down Expand Up @@ -183,7 +184,6 @@ h_coxreg_inter_effect.character <- function(x,
...) {
y <- as_factor_keep_attributes(x, verbose = verbose)
if (is.character(data[[effect]])) data[[effect]] <- as_factor_keep_attributes(data[[effect]], verbose = FALSE)
if (is.character(data[[covar]])) data[[covar]] <- as_factor_keep_attributes(data[[covar]], verbose = FALSE)

h_coxreg_inter_effect(
x = y,
Expand Down
2 changes: 1 addition & 1 deletion man/cox_regression_inter.Rd

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

0 comments on commit 0e459da

Please sign in to comment.