DSD_ReadStream(file, sep=",", k=NA, d=NA, take=NULL, assignment=NULL,
loop=FALSE)
close_stream(dsd)
DSD_ReadStream
.DSD_ReadStream
(subclass of DSD_R
,
DSD
).DSD_ReadStream
uses read.table()
to read in data from an R
connection. The connection is responsible for maintaining where the stream
is currently being read from. In general, the connections will consist of files
stored on disk but have many other possibilities (see connection
).The position in the file can be reset to the beginning using
reset_stream()
. The connection can be closed using close_stream()
.
DSD
,
reset_stream
,# creating data and writing it to disk
dsd <- DSD_Gaussians(k=3, d=5)
write_stream(dsd, "data.txt", n=100, sep=",")
# reading the same data back (as a loop)
dsd2 <- DSD_ReadStream("data.txt", sep=",", loop=TRUE)
dsd2
# clean up
close_stream(dsd2)
file.remove("data.txt")
# example with a part of the kddcup1999 data (take only cont. variables)
file <- system.file("examples", "kddcup10000.data.gz", package="stream")
dsd <- DSD_ReadStream(gzfile(file),
take=c(1, 5, 6, 8:11, 13:20, 23:41), assignment=42, k=7)
dsd
get_points(dsd,5)
# plot 100 points (projected on the first two principal components)
plot(dsd, n=100, method="pc")
close_stream(dsd)
Run the code above in your browser using DataLab