Rita94105 / PCA_CA

Create an interactive web service using ShinyApp to perform Principal Component Analysis (PCA) and Correspondence Analysis (CA).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Objective

  • Create an interactive web service using ShinyApp to perform Principal Component Analysis (PCA) and Correspondence Analysis (CA).

Getting Started

  1. Integrate Example Script: Integrating the folllowing script into a Shiny application. While ggbiplot is recommended for creating biplots in PCA, feel free to explore and use other packages suitable for PCA and CA if necessary.
data(iris)
# log transform 
log.ir <- log(iris[, 1:4])
ir.species <- iris[, 5]

# apply PCA - scale. = TRUE is highly advisable, but the default is FALSE. 
ir.pca <- prcomp(log.ir,center = TRUE, scale. = TRUE)

library(ggbiplot)
g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, groups = ir.species)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', legend.position = 'top')
print(g)
  1. Installation of ggbiplot: The ggbiplot package is not available on CRAN and must be installed from GitHub using the following command in RStudio:
devtools::install_github("vqv/ggbiplot")
  1. Connect Shinyapps.io with RStudio:
    • In RStudio, manage your ShinyApps.io accounts by navigating to Tools → Global Options → Publishing. This setup is crucial for publishing your application.

  2. Preview Application: After completing your Shiny application, preview it in the RStudio console using the appropriate command to initiate your app locally.
library(shiny)
shinyApp(ui = ui, server = server)
  1. Publish:
    • On the preview screen, locate the Publish button in the upper right corner. Click it to deploy your application to ShinyApps.io.

Important Notes

  • R Version: Ensure you are using R version 4 for this assignment.

Reference

Shiny

Bootstrap

PCA

About

Create an interactive web service using ShinyApp to perform Principal Component Analysis (PCA) and Correspondence Analysis (CA).


Languages

Language:R 100.0%