# Example 1: creating data and writing it to disk
stream <- DSD_Gaussians(k = 3, d = 2)
write_stream(stream, "data.txt", n = 100, info = TRUE, header = TRUE)
readLines("data.txt", n = 5)
# reading the same data back
stream2 <- DSD_ReadStream("data.txt", header = TRUE)
stream2
# get points
get_points(stream2, n = 5)
plot(stream2, n = 20)
# clean up
close_stream(stream2)
file.remove("data.txt")
# Example 2: Read part of the kddcup1999 data (take only cont. variables)
# col 42 is the class variable
file <- system.file("examples", "kddcup10000.data.gz", package = "stream")
stream <- DSD_ReadCSV(gzfile(file),
take = c(1, 5, 6, 8:11, 13:20, 23:41, .class = 42), k = 7)
stream
get_points(stream, 5)
# plot 100 points (projected on the first two principal components)
plot(stream, n = 100, method = "pca")
close_stream(stream)
Run the code above in your browser using DataLab