“…The points function can be used instead of labeling the # spectra with text samples = read.csv("sample names_no2_MA spectrum_first.csv", header=TRUE, sep=",", colClasses=c("character")) text(scores[,1],scores[,2], rownames(samples), col="blue", cex=0.7) # plots the scores as samples using text. Each number represents a different spectrum scatterplot3d(scores[,1:3], main = "PCA plot for First Derivative Modacrylic Spectra (1800-650cm-1)", xlab = paste("PC 1(", PC.var [1], "%)", sep = ""), ylab = paste("PC 2(", PC.var [2], "%)", sep = ""), zlab = paste("PC 3(", PC.var [3], "%)", sep = ""),pch=16, highlight.3d=TRUE, type="h") # creates a 3d plot for PC1 vs PC2 vs PC3 samples = read.csv("sample names_no2_MA spectrum_first.csv", header=TRUE, sep=",", colClasses=c("character")) text(scores[,1],scores[,2],scores [,3], rownames(samples)) # plots the scores as samples using text for 3d plot dev.off() # saves biplot for PC1 v PC2 as jpeg file 4. R-script for performing HCA on both the fingerprint region and alkane region of the FTIR data setwd("C:/Users/Theresa/Documents/Thesis/FTIR") getwd() # sets the working directory ##HCA on the fingerprint region FTIR = read.csv("data_no2_MA fingerprint_first.csv", header=TRUE, sep=",", row.names=1) head(FTIR) # reads in the file and confirms only the first 6 rows of each column rather than consuming the # workspace with the whole file dist.FTIR = dist(FTIR, method = "euclidean") # computes the distance matrix using Euclidean distance distsq.FTIR = dist.FTIR^2 # squares the distance matrix as needed for Ward's method hca.FTIR = hclust(distsq.FTIR, method = "ward") # performs HCA on distance matrix using Ward's method plot(hca.FTIR, labels = row.names(FTIR), main = "Cluster Dendrogram for First Derivative Modacrylic Spectra (1800-650cm-1)", lwd = 0.5, cex = 0.5) rect.hclust(hca.FTIR, h=10, border="red") # plots the HCA dendrogram with red borders around the clusters plot(1:448, hca.FTIR$height, xlab = "Wig Samples", ylab = "Linkage Distance", main = "Linkage Distances for First Derivative Modacrylic Spectra (1800-650cm-1) ", type = "p") # plots linkage distances to determine at what distance to cut the tree hca.…”