Skip to content

Commit c2b0c9b

Browse files
committed
Fix RecordArgs
1 parent 9e8bd39 commit c2b0c9b

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

R/General_RecordArgs.R

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,33 @@ RecordArgs <- function(ExportPath = NULL) {
170170
# # ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| #
171171

172172
# Evaluate each argument in the parent environment, with fallback to global
173-
# environment
173+
# environment, converting NULL defaults to scalar "NULL" for tibble
174+
# compatibility
175+
174176
evaluated_args <- lapply(combined_args, function(arg) {
175177
tryCatch(
176178
# Try evaluating the argument in the grandparent environment
177-
eval(arg, envir = parent_env),
179+
{
180+
result <- eval(arg, envir = parent_env)
181+
if (is.null(result)) {
182+
# Convert NULL results (e.g., from default arguments) to scalar "NULL"
183+
"NULL"
184+
} else {
185+
result
186+
}
187+
},
178188
error = function(e) {
179189
# If it fails, try the global environment as a fallback
180190
tryCatch(
181-
eval(arg, envir = globalenv()),
191+
{
192+
result <- eval(arg, envir = globalenv())
193+
if (is.null(result)) {
194+
# Convert NULL results to scalar "NULL" in fallback case too
195+
"NULL"
196+
} else {
197+
result
198+
}
199+
},
182200
error = function(e2) {
183201
# Return NA if evaluation fails in both environments
184202
NA

0 commit comments

Comments
 (0)