diff --git a/DESCRIPTION b/DESCRIPTION index 8174517..1d36738 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: Dmisc Title: Daniel miscellaneous functions -Version: 0.2.1 +Version: 0.3.0 Authors@R: person(given = "Daniel E.", family = "de la Rosa", diff --git a/NAMESPACE b/NAMESPACE index a7ab820..35b9d85 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +export("%...>%") +export("%<...%") export("%>%") export("%T>%") export(":=") diff --git a/R/unpack_assign.R b/R/unpack_assign.R index 5547fb1..b33b75a 100644 --- a/R/unpack_assign.R +++ b/R/unpack_assign.R @@ -1,4 +1,17 @@ +#' Unpack and assign values to specified names in an environment +#' `r lifecycle::badge("experimental")` +#' +#' @param names A character vector specifying the names of variables to be assigned. +#' @param values A list or vector containing the values to be assigned to the names. +#' @param .envir The environment where the variables will be assigned. Defaults to the global environment. +#' @param .warn Logical flag indicating whether to show a warning message. Defaults to TRUE. +#' +#' @return NULL. The function performs assignments in the specified environment. +#' @export +#' +#' @examples +#' c("x", "y") %<...% list(1, 2) `%<...%` <- function(names, values, .envir = .GlobalEnv, .warn = TRUE) { # Emitir una advertencia si 'warn' es TRUE if (.warn) { @@ -34,6 +47,21 @@ +#' Wrapper around `%<...%` to unpack and assign values to specified names in an environment +#' `r lifecycle::badge("experimental")` +#' +#' @param values A list or vector containing the values to be assigned to the names. +#' @param names A character vector specifying the names of variables to be assigned. +#' @param .envir The environment where the variables will be assigned. Defaults to the global environment. +#' @param .warn Logical flag indicating whether to show a warning message. Defaults to TRUE. +#' +#' @return NULL. The function performs assignments in the specified environment. +#' @export +#' +#' @examples +#' values <- list(1, 2) +#' names <- c("x", "y") +#' values %...>% names `%...>%` <- function(values, names, .envir = .GlobalEnv, .warn = TRUE) { `%<...%`(names, values, .envir = .envir, .warn = .warn) } diff --git a/man/grapes-...-greater-than-grapes.Rd b/man/grapes-...-greater-than-grapes.Rd new file mode 100644 index 0000000..56e58c1 --- /dev/null +++ b/man/grapes-...-greater-than-grapes.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/unpack_assign.R +\name{\%...>\%} +\alias{\%...>\%} +\title{Wrapper around \verb{\%<...\%} to unpack and assign values to specified names in an environment +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}} +\usage{ +values \%...>\% names +} +\arguments{ +\item{values}{A list or vector containing the values to be assigned to the names.} + +\item{names}{A character vector specifying the names of variables to be assigned.} + +\item{.envir}{The environment where the variables will be assigned. Defaults to the global environment.} + +\item{.warn}{Logical flag indicating whether to show a warning message. Defaults to TRUE.} +} +\value{ +NULL. The function performs assignments in the specified environment. +} +\description{ +Wrapper around \verb{\%<...\%} to unpack and assign values to specified names in an environment +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +} +\examples{ +values <- list(1, 2) +names <- c("x", "y") +values \%...>\% names +} diff --git a/man/grapes-less-than-...-grapes.Rd b/man/grapes-less-than-...-grapes.Rd new file mode 100644 index 0000000..8050b8c --- /dev/null +++ b/man/grapes-less-than-...-grapes.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/unpack_assign.R +\name{\%<...\%} +\alias{\%<...\%} +\title{Unpack and assign values to specified names in an environment +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}} +\usage{ +names \%<...\% values +} +\arguments{ +\item{names}{A character vector specifying the names of variables to be assigned.} + +\item{values}{A list or vector containing the values to be assigned to the names.} + +\item{.envir}{The environment where the variables will be assigned. Defaults to the global environment.} + +\item{.warn}{Logical flag indicating whether to show a warning message. Defaults to TRUE.} +} +\value{ +NULL. The function performs assignments in the specified environment. +} +\description{ +Unpack and assign values to specified names in an environment +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +} +\examples{ +c("x", "y") \%<...\% list(1, 2) +}