## embed a data.frame using a formula:
as.data.frame(
embed(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
iris, "PCA")
)
## embed a data.frame and return a data.frame
as.data.frame(embed(iris[, 1:4], "PCA"))
## embed a matrix and return a data.frame
as.data.frame(embed(as.matrix(iris[, 1:4]), "PCA"))
if (FALSE) {
## embed dimRedData objects
embed_methods <- dimRedMethodList()
quality_methods <- dimRedQualityList()
dataset <- loadDataSet("Iris")
quality_results <- matrix(NA, length(embed_methods), length(quality_methods),
dimnames = list(embed_methods, quality_methods))
embedded_data <- list()
for (e in embed_methods) {
message("embedding: ", e)
embedded_data[[e]] <- embed(dataset, e, .mute = c("message", "output"))
for (q in quality_methods) {
message(" quality: ", q)
quality_results[e, q] <- tryCatch(
quality(embedded_data[[e]], q),
error = function(e) NA
)
}
}
print(quality_results)
}
Run the code above in your browser using DataLab