Skip to content

Commit

Permalink
cleaner body on R side
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Aug 12, 2024
1 parent 3e870fd commit 38dac1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ fcoalesce = function(...) .Call(Ccoalesce, list(...), FALSE)
setcoalesce = function(...) .Call(Ccoalesce, list(...), TRUE)

fifelse = function(test, yes, no, na=NA) .Call(CfifelseR, test, yes, no, na)
fcase = function(..., default=NA) .Call(CfcaseR, parent.frame(), as.list(substitute(list(..., rep(TRUE, length(switch(1, ...))), default)))[-1L])
fcase = function(..., default=NA) {
default_condition <- suppressWarnings(rep(TRUE, length(switch(1, ...)))) # better than ..1/..elt(1): won't fail for empty fcase()
arg_list <- as.list(substitute(list(..., default_condition, default)))[-1L]
.Call(CfcaseR, parent.frame(), arg_list)
}

colnamesInt = function(x, cols, check_dups=FALSE, skip_absent=FALSE) .Call(CcolnamesInt, x, cols, check_dups, skip_absent)

Expand Down

0 comments on commit 38dac1d

Please sign in to comment.