Skip to content

Commit 58d3fe6

Browse files
authored
Update R_Intro.R
1 parent f290fed commit 58d3fe6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

R_Intro.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,14 @@ str(iris)
204204
# Note iris is a data.frame data type; this is simply a list.
205205

206206
## ----pca1
207-
data("iris")
207+
208+
209+
# Compute the correlation matrix
210+
# R= (1/n-1) X^T . X
211+
# Here X is our (centered and scaled) data matrix, n is the number of rows/observations in our data, and XT is the transpose of X.
212+
# (Hint: t(X) is transpose operator and A%*%B performs matrix multiplication on the matricies A and B) data("iris")
208213
# get numeric portions of list and make a matrix
214+
209215
X <- as.matrix(iris[1:4])
210216
# center and scale
211217
X <- scale(X,center = TRUE,scale=TRUE)

0 commit comments

Comments
 (0)