Skip to content

Commit 7d32b94

Browse files
committed
Fix lintr error
1 parent 6c3eb88 commit 7d32b94

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

R/internal.R

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -166,52 +166,52 @@
166166
hce_dat[idx, ]$step_values <-
167167
100 *
168168
stats::ecdf(hce_dat[hce_dat$arm == arm,
169-
]$t_cdf)(hce_dat[idx, ]$t_cdf)
169+
]$t_cdf)(hce_dat[idx, ]$t_cdf)
170170

171171
}
172172

173173
}
174174

175175
hce_ecdf <- hce_dat %>%
176-
dplyr::filter(outcome %in% step_outcomes) %>%
177-
unique()
178-
179-
# Double-check that all combinations of treatment and outcome have
180-
# been included (not the case if one combination has no patients)
181-
poss_comb <- expand.grid("outcome" = step_outcomes,
182-
"arm" = arm_levels)
183-
missing_row <- dplyr::anti_join(poss_comb,
184-
hce_ecdf[, c("outcome", "arm")])
185-
186-
# If there are missing rows, fill them in
187-
if (nrow(missing_row) > 0) {
188-
189-
for (i in 1:num_step_outcomes) {
190-
# Check if current step outcome is missing
191-
if (step_outcomes[[i]] %in% missing_row$outcome) {
192-
tmp <- missing_row[missing_row$outcome == step_outcomes[[i]], ]
193-
# Determine step values based on previous step if available
194-
if (i == 1) {
195-
step_values <- 0
196-
} else {
197-
tmp2 <- hce_ecdf[hce_ecdf$outcome == step_outcomes[i - 1] &
198-
hce_ecdf$arm == tmp$arm, ]
199-
step_values <- max(tmp2$step_values)
200-
}
201-
# Fetch existing data for the same outcome but different arm
202-
tmp3 <- hce_ecdf[hce_ecdf$outcome == step_outcomes[[i]] &
203-
hce_ecdf$arm != tmp$arm, ]
204-
# Append missing row to the main data frame
205-
hce_ecdf <-
206-
rbind(hce_ecdf,
207-
data.frame(outcome = step_outcomes[[i]],
208-
arm = tmp$arm,
209-
t_cdf = mean(tmp3$t_cdf),
210-
step_values = step_values,
211-
value = 0))
176+
dplyr::filter(outcome %in% step_outcomes) %>%
177+
unique()
178+
179+
# Double-check that all combinations of treatment and outcome have
180+
# been included (not the case if one combination has no patients)
181+
poss_comb <- expand.grid("outcome" = step_outcomes,
182+
"arm" = arm_levels)
183+
missing_row <- dplyr::anti_join(poss_comb,
184+
hce_ecdf[, c("outcome", "arm")])
185+
186+
# If there are missing rows, fill them in
187+
if (nrow(missing_row) > 0) {
188+
189+
for (i in 1:num_step_outcomes) {
190+
# Check if current step outcome is missing
191+
if (step_outcomes[[i]] %in% missing_row$outcome) {
192+
tmp <- missing_row[missing_row$outcome == step_outcomes[[i]], ]
193+
# Determine step values based on previous step if available
194+
if (i == 1) {
195+
step_values <- 0
196+
} else {
197+
tmp2 <- hce_ecdf[hce_ecdf$outcome == step_outcomes[i - 1] &
198+
hce_ecdf$arm == tmp$arm, ]
199+
step_values <- max(tmp2$step_values)
212200
}
201+
# Fetch existing data for the same outcome but different arm
202+
tmp3 <- hce_ecdf[hce_ecdf$outcome == step_outcomes[[i]] &
203+
hce_ecdf$arm != tmp$arm, ]
204+
# Append missing row to the main data frame
205+
hce_ecdf <-
206+
rbind(hce_ecdf,
207+
data.frame(outcome = step_outcomes[[i]],
208+
arm = tmp$arm,
209+
t_cdf = mean(tmp3$t_cdf),
210+
step_values = step_values,
211+
value = 0))
213212
}
214213
}
214+
}
215215

216216
# Order the data frame by step values
217217
hce_ecdf <- hce_ecdf[order(hce_ecdf$step_values), ]

0 commit comments

Comments
 (0)