I've the following helpers in my package (only mind the use of iwalk()
and <<-
):
add_suffixes <- function(data, cols, symbols) {
.cols <- predot(cols)
iwalk(symbols[names(cols)], \(value, key) {
if (is.null(value)) {
return()
}
if (key == "orcid") {
data <<- add_orcid_icons(data, value)
} else {
data <<- add_symbols(data, .cols[key], value)
}
})
data
}
crt_assign <- function(data) {
iwalk(.names$protected$crt, \(value, key) {
if (!has_name(data, key)) {
return()
}
data[key] <<- if_else(data[[key]] == 1L, value, NA)
})
data
}
I got the following comment from CRAN:
Please do not modify the global environment (e.g. by using <<-) in your
functions. This is not allowed by the CRAN policies.
I'm pretty certain that <<-
only modifies the parent environment (i.e. add_suffixes
and crt_assign
's environment here, not the global environment as stated in the comment).
Any advice on how to handle this comment?
This is my first submission so I've no clue how useful arguing is. I could certainly emulate iwalk()
with a pair of for
loops but that's my least favorite option because it really makes the code less readable…