From 868c8373578f3fe50f70581633e715495d5ef603 Mon Sep 17 00:00:00 2001 From: Friday Date: Wed, 25 Nov 2020 15:23:24 -0500 Subject: [PATCH] Assignment5 - Jiaxin Ling --- assignment5.Rmd | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/assignment5.Rmd b/assignment5.Rmd index 288bcb3..4634d46 100644 --- a/assignment5.Rmd +++ b/assignment5.Rmd @@ -16,7 +16,7 @@ The data you will be using comes from the Assistments online intelligent tutorin ## Start by uploading the data ```{r} -D1 <- +D1 <- read.csv("Assistments-confidence.csv") ``` @@ -38,8 +38,9 @@ ggcorr(D1[,-1], method = c("everything", "pearson")) #ggcorr() doesn't have an e ## Create a new data frame with the mean_correct variable removed, we want to keep that variable intact. The other variables will be included in our PCA. ```{r} -D2 <- - +library(tidyr) +library(dplyr) +D2 <- select(D1,2:4,6:8) ``` ## Now run the PCA on the new data frame @@ -72,15 +73,14 @@ plot(pca, type = "lines") ```{r} #Now, create a data frame of the transformed data from your pca. - -D3 <- +D3 <- data.frame(pca$x) #Attach the variable "mean_correct" from your original data frame to D3. +D3<- mutate(D3, mean_correct=D1$mean_correct) - -#Now re-run your correlation plots between the transformed data and mean_correct. If you had dropped some components would you have lost important infomation about mean_correct? - +#Now re-run your correlation plots between the transformed data and mean_correct. If you had dropped some components would you have lost important information about mean_correct? +ggcorr(D3, method = c("everything", "pearson")) ``` @@ -102,10 +102,16 @@ biplot(pca) ``` # Part III -Also in this repository is a data set collected from TC students (tc-program-combos.csv) that shows how many students thought that a TC program was related to andother TC program. Students were shown three program names at a time and were asked which two of the three were most similar. Use PCA to look for components that represent related programs. Explain why you think there are relationships between these programs. +Also in this repository is a data set collected from TC students (tc-program-combos.csv) that shows how many students thought that a TC program was related to another TC program. Students were shown three program names at a time and were asked which two of the three were most similar. Use PCA to look for components that represent related programs. Explain why you think there are relationships between these programs. ```{r} +D4 <- read.csv("tc-program-combos.csv") + +D5 <- select(D4, 2:50) + +pca2 <- prcomp(D5, scale. = TRUE) +biplot(pca2) ```