Skip to content

Commit

Permalink
style r
Browse files Browse the repository at this point in the history
  • Loading branch information
hoppanda committed Sep 3, 2024
1 parent 7fa809c commit 82164fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions R/binary-helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ get_pseudo_ipd_binary <- function(binary_agd, format = c("stacked", "unstacked")
#' @return a dataframe
#' @export

glm_makeup <- function(binobj, legend = "before matching", weighted = FALSE){
glm_makeup <- function(binobj, legend = "before matching", weighted = FALSE) {
ARM <- levels(binobj$data$ARM)
if (!weighted) {
N <- tapply(binobj$data$USUBJID, binobj$data$ARM, length)
Expand All @@ -107,12 +107,12 @@ glm_makeup <- function(binobj, legend = "before matching", weighted = FALSE){
N.EVNT.PERC <- N.EVNT * 100 / N
N.EVNT <- N.EVNT

data.frame(treatment = ARM,
type = rep(legend),
n = N,
events = N.EVNT,
`events%` = N.EVNT.PERC,
check.names = FALSE)
data.frame(
treatment = ARM,
type = rep(legend),
n = N,
events = N.EVNT,
`events%` = N.EVNT.PERC,
check.names = FALSE
)
}


8 changes: 4 additions & 4 deletions R/maic_anchored.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ maic_anchored_tte <- function(res,
medSurv_agd <- medSurv_makeup(kmobj_agd, legend = "AgD, external", time_scale = time_scale)
medSurv_out <- rbind(medSurv_ipd, medSurv_ipd_adj, medSurv_agd)
medSurv_out <- cbind(medSurv_out[, 1:6], `events%` = medSurv_out$events * 100 / medSurv_out$n.max, medSurv_out[7:ncol(medSurv_out)])

Check warning on line 256 in R/maic_anchored.R

View workflow job for this annotation

GitHub Actions / SuperLinter 🦸‍♀️ / Lint R code 🧶

file=R/maic_anchored.R,line=256,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 134 characters.
medSurv_out <- cbind(trt_ind = c("C","B","A")[match(medSurv_out$treatment,levels(dat$ARM))], medSurv_out)
medSurv_out <- cbind(trt_ind = c("C", "B", "A")[match(medSurv_out$treatment, levels(dat$ARM))], medSurv_out)

res$descriptive[["summary"]] <- medSurv_out

Expand Down Expand Up @@ -436,7 +436,7 @@ maic_anchored_binary <- function(res,
glmDesc_ipd_adj <- glm_makeup(binobj_ipd_adj, legend = "IPD, after matching", weighted = TRUE)
glmDesc_agd <- glm_makeup(binobj_agd, legend = "AgD, external", weighted = FALSE)
glmDesc <- rbind(glmDesc_ipd, glmDesc_ipd_adj, glmDesc_agd)
glmDesc <- cbind(trt_ind = c("C","B","A")[match(glmDesc$treatment,levels(dat$ARM))], glmDesc)
glmDesc <- cbind(trt_ind = c("C", "B", "A")[match(glmDesc$treatment, levels(dat$ARM))], glmDesc)
rownames(glmDesc) <- NULL
res$descriptive[["summary"]] <- glmDesc

Expand Down Expand Up @@ -471,14 +471,14 @@ maic_anchored_binary <- function(res,
res_AB_unadj <- bucher(res_AC_unadj, res_BC, conf_lv = 0.95)

# transform
transform_ratio <- function(resobj){
transform_ratio <- function(resobj) {
resobj$est <- exp(resobj$est)
resobj$se <- sqrt((exp(resobj$se^2) - 1) * exp(2 * resobj$est + resobj$se^2)) # log normal parameterization
resobj$ci_l <- exp(resobj$ci_l)
resobj$ci_u <- exp(resobj$ci_u)
resobj
}
transform_absolute <- function(resobj){
transform_absolute <- function(resobj) {
resobj$est <- resobj$est * 100
resobj$se <- resobj$se * 100
resobj$ci_l <- resobj$ci_l * 100
Expand Down
8 changes: 4 additions & 4 deletions R/maic_unanchored.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ maic_unanchored_tte <- function(res,
medSurv_dat <- medSurv_makeup(kmobj_dat, legend = "Before matching", time_scale = time_scale)
medSurv_dat_adj <- medSurv_makeup(kmobj_dat_adj, legend = "After matching", time_scale = time_scale)
medSurv_out <- rbind(medSurv_dat, medSurv_dat_adj)
medSurv_out <- cbind(trt_ind = c("B","A")[match(medSurv_out$treatment,levels(dat$ARM))], medSurv_out)
medSurv_out <- cbind(trt_ind = c("B", "A")[match(medSurv_out$treatment, levels(dat$ARM))], medSurv_out)

res$descriptive[["summary"]] <- medSurv_out

Expand Down Expand Up @@ -375,7 +375,7 @@ maic_unanchored_binary <- function(res,
glmDesc_dat <- glm_makeup(binobj_dat, legend = "Before matching", weighted = FALSE)
glmDesc_dat_adj <- glm_makeup(binobj_dat_adj, legend = "After matching", weighted = TRUE)
glmDesc <- rbind(glmDesc_dat, glmDesc_dat_adj)
glmDesc <- cbind(trt_ind = c("B","A")[match(glmDesc$treatment,levels(dat$ARM))], glmDesc)
glmDesc <- cbind(trt_ind = c("B", "A")[match(glmDesc$treatment, levels(dat$ARM))], glmDesc)
rownames(glmDesc) <- NULL
res$descriptive[["summary"]] <- glmDesc

Expand All @@ -394,14 +394,14 @@ maic_unanchored_binary <- function(res,
res_AB_unadj$pval <- summary(binobj_dat)$coefficients[2, "Pr(>|z|)"]

# : transform
transform_ratio <- function(resobj){
transform_ratio <- function(resobj) {
resobj$est <- exp(resobj$est)
resobj$se <- sqrt((exp(resobj$se^2) - 1) * exp(2 * resobj$est + resobj$se^2)) # log normal parameterization
resobj$ci_l <- exp(resobj$ci_l)
resobj$ci_u <- exp(resobj$ci_u)
resobj
}
transform_absolute <- function(resobj){
transform_absolute <- function(resobj) {
resobj$est <- resobj$est * 100
resobj$se <- resobj$se * 100
resobj$ci_l <- resobj$ci_l * 100
Expand Down

0 comments on commit 82164fd

Please sign in to comment.