Skip to content

Commit 86513d1

Browse files
Fix CodeFactor maintainability and style issues in func_discord_data.R (#57)
* Initial plan * Fix maintainability and style issues in func_discord_data.R Co-authored-by: smasongarrison <6001608+smasongarrison@users.noreply.github.com> * Apply suggestion from @smasongarrison Signed-off-by: Mason Garrison <garrissm@wfu.edu> --------- Signed-off-by: Mason Garrison <garrissm@wfu.edu> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: smasongarrison <6001608+smasongarrison@users.noreply.github.com> Co-authored-by: Mason Garrison <garrissm@wfu.edu>
1 parent e90f0ff commit 86513d1

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

R/func_discord_data.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,25 @@ discord_data_ram_optimized <- function(data,
9898
orderedOnOutcome <- do.call(
9999
rbind,
100100
lapply(
101-
X = 1:nrow(data),
101+
X = seq_len(nrow(data)),
102102
FUN = check_sibling_order,
103103
data = data, outcome = outcome,
104104
pair_identifiers = pair_identifiers
105105
)
106106
)
107107

108108
if (!valid_ids(orderedOnOutcome,
109-
id = id
110-
)) {
109+
id = id
110+
)) {
111111
id <- "rowwise_id"
112-
orderedOnOutcome <- cbind(orderedOnOutcome, rowwise_id = 1:nrow(data))
112+
orderedOnOutcome <- cbind(orderedOnOutcome, rowwise_id = seq_len(nrow(data)))
113113
}
114114

115115
out <- vector(mode = "list", length = length(variables))
116116

117-
for (i in 1:length(variables)) {
117+
for (i in seq_along(variables)) {
118118
out[[i]] <- do.call(rbind, lapply(
119-
X = 1:nrow(orderedOnOutcome),
119+
X = seq_len(nrow(orderedOnOutcome)),
120120
FUN = make_mean_diffs,
121121
data = orderedOnOutcome, id = id,
122122
sex = sex, race = race,
@@ -184,11 +184,11 @@ discord_data_ram_optimized <- function(data,
184184
}
185185

186186

187-
return(output)
187+
output
188188
}
189189
.clean_names <- function(df) {
190190
names(df) <- sub(".*\\.", "", names(df)) # If name has "prefix.name", keep only "name"
191-
return(df)
191+
df
192192
}
193193
#' @title Discord Data Fast
194194
#'
@@ -220,13 +220,13 @@ discord_data_fast <- function(data,
220220
)
221221

222222
if (!valid_ids(orderedOnOutcome,
223-
id = id
223+
id = id
224224
)) {
225225
id_original <- id
226226
id <- "rowwise_id"
227227
orderedOnOutcome <- cbind(orderedOnOutcome,
228228
id_original = data[id_original],
229-
rowwise_id = 1:nrow(data)
229+
rowwise_id = seq_len(nrow(data))
230230
)
231231
}
232232

@@ -307,5 +307,5 @@ discord_data_fast <- function(data,
307307
}
308308

309309

310-
return(output)
310+
output
311311
}

0 commit comments

Comments
 (0)