R/append_cmisc.R

Defines functions append_cmisc

Documented in append_cmisc

#' append an element to a list, the cmisc way
#'
#' @param mylist a list
#' @param new_element a new element to append to the list
#' @return A list with the new element appended
#' @examples
#' library(magrittr)
#' aa <- aa_old <- list()
#' aa_old %<>% append(1:10)
#' aa %<>% append_cmisc(1:10)
#' aa; aa_old
#'
#' @export
append_cmisc <- function(mylist, new_element) {
  mylist[[length(mylist)+1]] <- new_element
  return(mylist)
}
PatrickCoyle/cmisc documentation built on June 23, 2022, 3:07 p.m.