Skip to content

Commit

Permalink
Renamed function.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicChr committed Sep 25, 2024
1 parent 5f8f29c commit e5fa55d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export(na_find)
export(na_insert)
export(na_replace)
export(na_rm)
export(named_dots)
export(named_list)
export(new_df)
export(new_list)
export(num_na)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ which is approximately 9.223372e+18 and errors if that limit is exceeded.
* 'integer64' objects are now lightly supported. They are not
supported in any sequence functions or in the 'set_math' functions.

* New functions `new_df` and `named_dots`.
* New functions `new_df` and `named_list`.

* All factor levels utilities now begin with the prefix 'levels_'.

Expand Down
11 changes: 6 additions & 5 deletions R/dots.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@
#'
#'
#' @param ... Key-value pairs.
#' @param .keep_null Should `NULL` entries be kept? Default is `TRUE`.
#'
#' @returns A named list.
#'
#' @rdname dots
#' @export
named_dots <- function(...){
named_list <- function(..., .keep_null = TRUE){
dots <- list(...)
if (!.keep_null){
dots <- cpp_list_rm_null(dots)
}

dot_nms <- names(dots)

if (is.null(dot_nms)){
names(dots) <- expr_names(...)
} else if (!all(nzchar(dot_nms))){
empty <- which_(!nzchar(dot_nms))
empty <- which_(nzchar(dot_nms), invert = TRUE)
expr_nms <- expr_names(...)
dot_nms[empty] <- expr_nms[empty]
names(dots) <- dot_nms
Expand All @@ -29,6 +33,3 @@ expr_names <- function(...){
as.character(substitute(c(...))[-1L])
# vapply(substitute(alist(...))[-1L], deparse2, "", USE.NAMES = FALSE)
}
list_named <- function(...){
cpp_list_rm_null(named_dots(...))
}
2 changes: 1 addition & 1 deletion R/new_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' @export
new_df <- function(..., .nrows = NULL, .recycle = FALSE, .name_repair = FALSE){

out <- list_named(...)
out <- named_list(..., .keep_null = FALSE)

# Recycle
if (.recycle){
Expand Down
8 changes: 5 additions & 3 deletions man/dots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e5fa55d

Please sign in to comment.