knitr::opts_chunk$set(echo = TRUE)
getwd()
ddt = read.csv("DDT.csv") head(ddt)
- Qualitative variables are
RIVER and SPECIES.
- Quantitative variables are
MILE, LENGTH, WEIGHT, DDT.
- Using
length(unique(ddt$SPECIES))
I found3 unique species.
- Subset showing only
LMBASS > 800gms
(directly below).
subset(ddt, ddt$SPECIES == "LMBASS" & ddt$WEIGHT > 800)
- Subset showing only
RIVER SCM
andDDT > 4.0
(directly below).
subset(ddt, ddt$RIVER == "SCM" & ddt$DDT > 4.0)
- Mean length found with mean(ddt$LENGTH) or summary(ddt) and is
42.81
- Standard deviation of the weight of fish is
376.5461
No.
Although the axes are correct, the data is inverse.- The last value of v / 20 is
1.00
table(ddt$RIVER)
barplot(with(ddt,table(RIVER)),col=1:4, xlab = "Rivers", ylab = "# of ish measured")
data <- with(ddt,table(RIVER, SPECIES)) data
data <- with(ddt,table(RIVER, SPECIES)) barplot(data,ylim = c(0, 100), col=1:4,beside = T, legend.text = c("FCM", "LCM", "SCM", "TRM"), xlab = "Species", ylab = "# of fish measured", args.legend = list(x="topleft",title="Rivers") )
species <- with(ddt, table(SPECIES)) pie(species,col = 1:3,main = "Species distribution")
rivers <- with(ddt, table(RIVER)) pie(rivers,col = 1:4,main = "Distribution of rivers where fish were measured")
layout(matrix(c(1,2,3),nr=1,nc=3))# 1 row 3 cols with(ddt,boxplot(LENGTH,ylab="LENGTH",col="Blue",notch=TRUE)) with(ddt,boxplot(WEIGHT,ylab="WEIGHT",col="Green",notch=TRUE)) with(ddt,boxplot(DDT,ylab="DDT",col="Red",notch=TRUE))
Note: The instructions say LENGTH vs WEIGHT, so I've put Length on the Y-axis and Weight on the X-axis as I've been trained by previous math courses.
coplot(LENGTH~WEIGHT|RIVER,data=ddt)
coplot(DDT~WEIGHT|SPECIES,data=ddt)
library(ggplot2) p <- ggplot(ddt, aes(x=SPECIES, y=WEIGHT, fill=RIVER)) + geom_boxplot() + ggtitle(label = "Adam Gracy") p
library(ggplot2) p <- ggplot(ddt, aes(x=RIVER, y=LENGTH, fill = SPECIES)) + geom_violin() + ggtitle("Adam Gracy") p
library(ggplot2) p <- ggplot(ddt,aes(x=WEIGHT, y= LENGTH, color=SPECIES)) + geom_point() + ggtitle("Adam Gracy") p
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.