---
title: "Introduction to booklet"
output: rmarkdown::html_vignette
description: >
  Start here if this is your first time using booklet.
  This document deals with the differences between FactoMineR and booklet.
vignette: >
  %\VignetteIndexEntry{Introduction to booklet}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r echo = FALSE, message = FALSE}
knitr::opts_chunk$set(collapse = T, comment = "#>")
```

## Introduction

The R package booklet is designed for multivariate data analysis. It offers a wide array of statistical techniques for exploratory data analysis, including principal component analysis (PCA). booklet is user-friendly and provides comprehensive tools for visualizing and interpreting complex data structures, making it a valuable resource for researchers and data analysts. 

```{r message = FALSE, warning=FALSE}
library(booklet)
X <- iris[, 1:4]
head(X)
```

## Standardize the dataset

Before performing a PCA, it is important to standardize the dataset. This ensures that all variables are on the same scale, which is necessary for accurate results. In this example, the dataset is standardized by subtracting the mean and dividing by the standard deviation.

$$ (X - \bar{X}) / \sigma $$

```{r}
X_scaled <- pca_standardize_norm(X, center = TRUE, scale = TRUE)
head(X_scaled)
```

## Compute eigenvalues

The next step is to compute the eigenvalues and eigenvectors of the covariance matrix. This is done using the `get_eigen()` function in R. The eigenvalues represent the variance explained by each principal component, while the eigenvectors represent the direction of the principal components in the original feature space.

```{r}
eigs <- pca_eigen(X_scaled)
```

## Perform PCA

Finally, we can perform a principal component analysis (PCA) on the standardized dataset. This will reduce the dimensionality of the data and identify the principal components that explain the most variance.

```{r}
# You can also use the `pca_ind_coords()` function.
ind_coords <- t(t(as.matrix(eigs[["U"]])) * sqrt(eigs[["values"]]))
head(ind_coords)
```
