我想获得PC1和PC2的结果,以便在与Tableau Desktop相同的图形中绘制两者的courbe。 怎么办?
data = read.csv(file="data.csv",header=TRUE, sep=";")
data.active <- data[, 1:30]
library(factoextra)
res.pca <- prcomp(data.active,center = TRUE, scale. = TRUE)
fviz_eig(res.pca)
答案 0 :(得分:0)
我认为您需要编写一个csv,其结果在R和Tableau之间。该代码如下所示:
# Principal Components Analysis
res.pca <- stats::prcomp(iris[,-5],center = TRUE, scale. = TRUE)
# Choose number of dimension kept
factoextra::fviz_eig(res.pca)
# Some visualisation
factoextra::fviz_pca_var(res.pca)
factoextra::fviz_pca_ind(res.pca)
factoextra::fviz_pca_biplot(res.pca)
# access transformed points
str(res.pca)
res.pca$x
# save points in csv to use outside of R
utils::write.csv(x = res.pca$x, file = "path/data_pca.csv")
# Load your data and do graphs the usual way with tableau
我使用?prcomp
查找结果中的数据,您还可以进一步进行分析,并使用带有R的一些漂亮的图形(单个/变量的双图,聚类,...)(仅导入图像)在Tableau中)使用:link