knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
A package is a fundamental unit of reproducible R code which include reusable R functions along with their documentation and sample data.
Documentation about package making in R can be found at https://r-pkgs.org/
In this Lab1 exercise, I have created an R package "Lab1Intro" that contains three functions to create from a data array X:
My package is available at the github repository https://github.com/abinashborah/Lab1Intro
$$\overline{x}k = \frac{1}{n}\sum{j=1}^{n} x_{jk}\hspace{1cm}k = 1, 2,...,p$$
$${s}{ik} = \frac{1}{n}\sum{j=1}^{n} (x_{ji}-\overline{x}i)(x{jk}-\overline{x}_k) \hspace{1cm}i = 1, 2,...,p,\hspace{0.5cm}k = 1, 2,...,p$$
$${r}{ik} = \frac{{s}{ik}}{{\sqrt{{s}{ii}}}{\sqrt{{s}{kk}}}} = \frac{\sum_{j=1}^{n} (x_{ji}-\overline{x}i)(x{jk}-\overline{x}k)} {\sqrt{\sum{j=1}^{n}(x_{ji}-\overline{x}i)^2}\sqrt{\sum{j=1}^{n}(x_{jk}-\overline{x}_k)^2}} \hspace{1cm}i = 1, 2,...,p,\hspace{0.5cm}k = 1, 2,...,p$$
$$\textbf{S} = \frac{1}{n-1}\textbf{X}^/\left(\textbf{I} - \frac{1}{n}\textbf{11}^/\right)\textbf{X}$$
\usepackage{amsmath}
$$\textbf{D}^{1/2} = \begin{bmatrix} \sqrt{s_{11}} & 0 & \cdots & 0 \ 0 & \sqrt{s_{22}} & \cdots & 0 \ \vdots & \vdots & \ddots & \vdots \ 0 & 0 & \cdots & \sqrt{s_{pp}} \end{bmatrix}$$
$$\textbf{R} = \textbf{D}^{{-1}/{2}}\textbf{S}\textbf{D}^{{-1}/{2}}$$
# Loading the package library(Lab1Intro) # Loading the data data("T1_2") # Finding the mean vector for the data array using the function mean_vector() Lab1Intro::mean_vector(T1_2) # Finding the covariance matrix for the data array using the function covariance_matrix() Lab1Intro::covariance_matrix(T1_2) # Finding the correlation matrix for the data array using the function correlation_matrix() Lab1Intro::correlation_matrix(T1_2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.