# NOT RUN {
#generate cockscrew-shaped 3D data with 3 additional noisy dimensions
ts <- c(rnorm(100), rnorm(200, 5), rnorm(150, 13), runif(200, min = -5, max = 20))
a <- 3
w <- 1
points <- cbind(30*cos(w * ts), 30*sin(w * ts), a * ts)
ndim <- 6
noise <- cbind(matrix(rnorm(length(ts) * 3, sd = 5), ncol = 3),
matrix(rnorm(length(ts) * (ndim - 3), sd = 10), ncol = ndim - 3))
data <- noise
data[, 1:3] <- data[, 1:3] + points
pca <- prcomp(data)
# }
# NOT RUN {
#compare Euclidean distance with the real position on the helix
sleepwalk(list(pca$x[, 1:2], pca$x[, 1:2]), list(data, as.matrix(ts)),
compare = "distances", pointSize = 3)
# }
# NOT RUN {
#the same, but with saving the web page to an HTML file
sleepwalk(list(pca$x[, 1:2], pca$x[, 1:2]), list(data, as.matrix(ts)),
compare = "distances", pointSize = 3,
saveToFile = paste0(tempdir(), "/test.html"))
# }
Run the code above in your browser using DataLab