# DAL ToolBox # version 1.0.777 source("https://raw.githubusercontent.com/cefet-rj-dal/daltoolbox/main/jupyter.R") #loading DAL load_library("daltoolbox") #for ploting load_library("ggplot2") load_library("dplyr") wine <- get(load(url("https://raw.githubusercontent.com/cefet-rj-dal/daltoolbox/main/wine.RData"))) head(wine) pca_res = prcomp(wine[,2:ncol(wine)], center=TRUE, scale.=TRUE) y <- cumsum(pca_res$sdev^2/sum(pca_res$sdev^2)) x <- 1:length(y) dat <- data.frame(x, value = y, variable = "PCA") dat$variable <- as.factor(dat$variable) head(dat) grf <- plot_scatter(dat, label_x = "dimensions", label_y = "cumulative variance", colors="black") + theme(text = element_text(size=16)) plot(grf) myfit <- fit_curvature_min() res <- transform(myfit, y) head(res) plot(grf + geom_vline(xintercept = res$x, linetype="dashed", color = "red", size=0.5))