Hi,
I was creating plots for pca analysis as follows:
new <- data.frame(days_to_last_follow_up, age_at_index, age_at_diagnosis, ajcc_pathologic_t, ajcc_pathologic_m, ajcc_pathologic_n, gender)
scaled_new<- apply(nowy[,1:3], 2, scale)
new.pca <- prcomp(scaled_new, center=TRUE, scale.=TRUE)
new.k <- new[,4]
fviz_pca_biplot(new.pca, geom = "point", habillage = new.k, repel = "TRUE")
new.k1 <- new[,5]
fviz_pca_biplot(new.pca, geom = "point", habillage = new.k1, repel = "TRUE")
new.k2 <- new[,6]
fviz_pca_biplot(new.pca, geom = "point", habillage = new.k2, repel = "TRUE")
new.k3 <- new[,7]
fviz_pca_biplot(new.pca, geom = "point", habillage = new.k3, repel = "TRUE")
Is it possible to create a loop that shows four plots on one page? I tried this way, but it only shows in the R window.
par(mfrow=c(4,1))
for (i in 4:7) {
df <- new[,i]
b <- fviz_pca_biplot(df, geom = "point", habillage = df, repel = "TRUE")
print(b)
}
par(mfrow=c(1,1))
Thanks for help