R/write_list.R

Defines functions write_list

Documented in write_list

#' Writes a list to a path
#'
#' @param x A list.
#' @param path A full path to file.
#' @return A file named `list.txt` in `path`.
#' @examples
#' \dontrun{
#' library(voice)
#'
#' pts <- list(x = cars[,1], y = cars[,2])
#' listFile <- paste0(tempdir(), '/list.txt')
#' voice::write_list(pts, listFile)
#' file.info(listFile)
#' system(paste0('head ', listFile))
#' }
#' @export
write_list <- function(x, path){
  sink(path)
  print(x)
  sink()
}

Try the voice package in your browser

Any scripts or data that you put into this service are public.

voice documentation built on April 19, 2023, 5:09 p.m.