format_stream: Set the format for a stream_file object

View source: R/stream.R

format_streamR Documentation

Set the format for a stream_file object

Description

The format is set on the file objects inside the list so that the file object can be used to call a write method. See write_stream().

Usage

format_stream(
  x,
  type = c("fst", "feather", "qs", "rds"),
  set_ext = TRUE,
  warn = FALSE
)

Arguments

x

A file_stream object.

type

The file format type; if feather is chosen, then a check will be made to ensure the arrow package is loaded.

set_ext

If TRUE, the existing extension (if it exists) is stripped and a new extension is added based on the value of type.

warn

If TRUE a warning will be issued in case the output format is set but there is no directory path associated with the file spot in x[[1]].

Value

x is returned with a new class attribute reflecting the expected output format (fst, feather (arrow), qs or rds).

See Also

format_is_set(), locate_stream(), ext_stream(), new_stream(), file_stream(), file_set()

Examples

fs <- new_stream(2)
fs <- format_stream(fs, "fst")
fs[[1]]

format_is_set(fs[[1]])  
 

mrgsim.parallel documentation built on March 18, 2022, 7:52 p.m.