Download src/test2.R from Myxogastria0808/loadings-web-api-sample: direct link, hf CLI and curl.
- Browser
- Download file 942 Bytes
-
https://huggingface.co/spaces/Myxogastria0808/loadings-web-api-sample/resolve/main/src/test2.R
- Command line
-
hf download hf://spaces/Myxogastria0808/loadings-web-api-sample/src/test2.R
-
curl -L -o test2.R https://huggingface.co/spaces/Myxogastria0808/loadings-web-api-sample/resolve/main/src/test2.R
942 Bytes
| library("loadings") # ロード | |
| data(fasting) # テストデータ読み込み | |
| pca <- prcomp(fasting$X, scale=TRUE) # 主成分分析 | |
| pca <- pca_loading(pca) # 主成分分析の因子負荷量の検定 | |
| current_path <- getwd() | |
| setwd(paste(current_path, "/data", sep="")) | |
| paste("png files output path: ", getwd(), sep="") | |
| # 因子負荷量の分布 | |
| layout(cbind(1:5, 6:10)) | |
| for(i in seq(10)){ | |
| mycol <- ifelse(sort(pca$loading$R[,i]) > 0, yes="green2", no="red2") | |
| png(paste("test2-Correlation-Coefficien-", i, ".png", sep=""), width=800, height=800) | |
| barplot(sort(pca$loading$R[,i]), | |
| col=mycol, | |
| main=paste0("Loading ", i, " (Correlation Coefficient)")) | |
| dev.off() | |
| } | |
| # p値の分布 | |
| layout(cbind(1:5, 6:10)) | |
| for(i in seq(10)){ | |
| png(paste("test2-P-value-", i, ".png", sep=""), width=800, height=800) | |
| barplot(sort(pca$loading$p.value[,i]), | |
| main=paste0("Loading ", i, " (P-value)")) | |
| dev.off() | |
| } | |