write_stream: Write a Data Stream to a File

View source: R/write_stream.R

write_streamR Documentation

Write a Data Stream to a File

Description

Writes points from a data stream DSD object to a file or a connection.

Usage

write_stream(
  dsd,
  file,
  n,
  block = 100000L,
  info = FALSE,
  append = FALSE,
  sep = ",",
  header = FALSE,
  row.names = FALSE,
  close = TRUE,
  ...
)

Arguments

dsd

The DSD object that will generate the data points for output.

file

A file name or a R connection to be written to.

n

The number of data points to be written. For finite streams, n = -1 writes all available data points.

block

Write stream in blocks to improve file I/O speed.

info

Save the class/cluster labels and other information columns with the data.

append

Append the data to an existing file. If FALSE, then the file will be overwritten.

sep

The character that will separate attributes in a data point.

header

A flag that determines if column names will be output (equivalent to col.names in write.table()).

row.names

A flag that determines if row names will be output.

close

close stream after writing.

...

Additional parameters that are passed to write.table().

Value

There is no value returned from this operation.

Author(s)

Michael Hahsler

See Also

write.table

Examples

# create data and write 10 points to disk
stream <- DSD_Gaussians(k = 3, d = 5)
stream

write_stream(stream, file="data.txt", n = 10, header = TRUE, info = TRUE)

readLines("data.txt")

# clean up
file.remove("data.txt")

# create a finite stream and write all data to disk using n = -1
stream2 <- DSD_Memory(stream, n = 5)
stream2

write_stream(stream2, file="data.txt", n = -1, header = TRUE, info = TRUE)

readLines("data.txt")

# clean up
file.remove("data.txt")

stream documentation built on May 29, 2024, 9:43 a.m.