###################################################################### # R commands Stat 515 # Lab 1 University of South Carolina ###################################################################### # This file contains the R commands for the lab. # # Lines beginning with the symbol '#' are comments in R. All other # lines contain code. # # In R for Windows, you may wish to open this file from the menu bar # (File:Display file); you can then copy commands into the command # window. (Use the mouse to highlight one or more lines; then # right-click and select "Paste to console".) ###################################################################### #### run install.packagtes if you have not done it before ###install.packages("NADA") ### install.packages("GGally") library(NADA) library(GGally) data(HgFish) head(HgFish) #setwd("/Users/hoyen/Desktop/STAT515-2026/Notes") pm <- ggpairs(HgFish, columns = c(3, 4, 5)) png("FishMatrix.png") pm dev.off() hist(HgFish$Weight, main="Fish Weight", xlab="Kg") png("FishWeight.png") hist(HgFish$Weight, main="Fish Weight", xlab="Kg") dev.off() png("FishLength.png") hist(HgFish$Length, main="Fish Length", xlab="mm") dev.off() x<-HgFish$Length # Sample data # Define breaks at every 10 increments, covering the data range breaks <- seq(floor(min(x)/10)*10, ceiling(max(x)/10)*10, by = 10) # Create the histogram png("FishLengthFine.png") hist(x, breaks = breaks, main = "Fish Length Histogram (Bin Width = 10)", xlab = "ppm", ylab = "Frequency", col = "steelblue", border = "white") dev.off()