Creating a Markdown Report for Module 3 Exercise Part 2

The squid dataset is used for this exercise. It contains observations of squid capture around Scotland.

The squid dataset is read into the file and assigned a value.

squid = read.csv("squid.csv")

The first plot creates a histogram that displays the gonadosomatic index (GSI) of all the squids.

hist(squid$GSI, xlab = "GSI", main = "Histogram of Squid GSI", 
     ylim = c(0,1350))

The code also changes the title of the x axis (xlab), the title of the plot (main), and the limit of the y axis (ylim).

The next plots are separate histograms that display the GSI values of (1) male squids

hist(squid$GSI[squid$Sex == 1], col = 'blue', xlab = "GSI", 
     ylim = c(0,700), main = "Histogram of Male Squid GSI")

and (2) female squids

hist(squid$GSI[squid$Sex == 2], col = 'red', xlab = "GSI", 
     ylim = c(0,700), main = "Histogram of Female Squid GSI")

In these plots, the color is also changed (col).

The third plot is a boxplot which shows the relationship of the GSI to the sex of the squid.

squid$log.GSI = log(squid$GSI)
boxplot(log.GSI ~ Sex, data = squid, main = 'GSI vs. Sex of Squids', ylab = 
          "GSI (log)")

The GSI values were first put through a function to make them a logarithm (log()) so that the differences between the sexes can be more clearly shown.

The final plot is a boxplot which shows the relationship of the GSI to the locations were the squid were caught.

boxplot(log.GSI ~ Location, data = squid, main = 'GSI vs. Location of Squids',
        ylab = 'GSI(log)')