Skip to contents

Resets the position in a DSD object to the beginning or, if available, any other position in the stream.

Usage

reset_stream(dsd, pos = 1)

Arguments

dsd

An object of class a subclass of DSD which implements a reset function.

pos

Position in the stream (the beginning of the stream is position 1).

Details

Resets the counter of the stream object. For example, for DSD_Memory, the counter stored in the environment variable is moved back to 1. For DSD_ReadCSV objects, this is done by calling seek() on the underlying connection.

reset_stream() is implemented for:

Author

Michael Hahsler

Examples

# initializing the objects
stream <- DSD_Gaussians()
replayer <- DSD_Memory(stream, 100)
replayer
#> Memorized Stream for Gaussian Mixture (d = 2, k = 3) 
#> Class: DSD_Memory, DSD_R, DSD 
#> Contains 100 data points - currently at position 1 - loop is FALSE 

p <- get_points(replayer, 50)
replayer
#> Memorized Stream for Gaussian Mixture (d = 2, k = 3) 
#> Class: DSD_Memory, DSD_R, DSD 
#> Contains 100 data points - currently at position 51 - loop is FALSE 

# reset replayer to the beginning of the stream
reset_stream(replayer)
replayer
#> Memorized Stream for Gaussian Mixture (d = 2, k = 3) 
#> Class: DSD_Memory, DSD_R, DSD 
#> Contains 100 data points - currently at position 1 - loop is FALSE 

# set replayer to position 21
reset_stream(replayer, pos = 21)
replayer
#> Memorized Stream for Gaussian Mixture (d = 2, k = 3) 
#> Class: DSD_Memory, DSD_R, DSD 
#> Contains 100 data points - currently at position 21 - loop is FALSE