R/name_element.R

Defines functions name_element

Documented in name_element

#' Place name of list as attribute within the element
#'
#' Where we want the name of the list to be accessible within a loop or function, we can
#' use this function to place the name within the list element as an attribute.
#'
#' @param x list
#'
#' @return list with names as attributes
name_element <- function(x){
  for (i in 1:length(x)) {
    attr(x[[i]],'element_name') <- names(x)[i]
  }
  return(x)
}
OpenSourceMindshare/surveytools documentation built on Aug. 14, 2019, 10:38 a.m.