diff --git a/Module-3-Example-1.R b/Module-3-Example-1.R new file mode 100644 index 0000000..b586389 --- /dev/null +++ b/Module-3-Example-1.R @@ -0,0 +1,28 @@ + +# Create a vector for hights +height <- c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175) + +# Create a vector for bodymass +bodymass <- c(82, 49, 53, 112, 47, 69, 77, 71, 62, 78) + +# Create a scotterplot +plot(bodymass, height) + +# A better scotterplot +plot(bodymass, height, pch = 16, cex = 1.3, col = "blue", main = "HEIGHT PLOTTED AGAINST BODY MASS", xlab = "BODY MASS (kg)", ylab = "HEIGHT (cm)") + + +# Correlation +cor(bodymass, height) + +cor(height, bodymass,) + +# A simple linear regression +m<-lm(height ~ bodymass) + +# A line on the past plot +# abline(98.0054, 0.9528) + +# better would be to do this. +abline(m) + diff --git a/R-Example-Program-4.R b/Module-3-Example-2.R similarity index 99% rename from R-Example-Program-4.R rename to Module-3-Example-2.R index 2b491da..bfe7c19 100644 --- a/R-Example-Program-4.R +++ b/Module-3-Example-2.R @@ -48,8 +48,6 @@ summary(my.model) # create Analysis of Variance Table anova(my.model) - - # fitted values of my model fitted(my.model) @@ -57,13 +55,5 @@ fitted(my.model) resid(my.model) - - - - - - - - # As an extra task describe what these plots are plot(my.model) diff --git a/R-Example-Program-5.R b/Module-3-Example-3.R similarity index 100% rename from R-Example-Program-5.R rename to Module-3-Example-3.R diff --git a/R-Example-Program-4.1.R b/R-Example-Program-4.1.R deleted file mode 100644 index 7eae16e..0000000 --- a/R-Example-Program-4.1.R +++ /dev/null @@ -1,20 +0,0 @@ - -height <- c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175) - - -bodymass <- c(82, 49, 53, 112, 47, 69, 77, 71, 62, 78) - - -plot(bodymass, height) - - -plot(bodymass, height, pch = 16, cex = 1.3, col = "blue", main = "HEIGHT PLOTTED AGAINST BODY MASS", xlab = "BODY MASS (kg)", ylab = "HEIGHT (cm)") - - -lm(height ~ bodymass) - - -abline(98.0054, 0.9528) - -abline(lm(height ~ bodymass)) - diff --git a/R-Example-Program-4.2.R b/R-Example-Program-4.2.R deleted file mode 100644 index 561fcbe..0000000 --- a/R-Example-Program-4.2.R +++ /dev/null @@ -1,21 +0,0 @@ - - -height <- c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175) - - -bodymass <- c(82, 49, 53, 112, 47, 69, 77, 71, 62, 78) - - -plot(bodymass, height) - - -plot(bodymass, height, pch = 16, cex = 1.3, col = "blue", main = "HEIGHT PLOTTED AGAINST BODY MASS", xlab = "BODY MASS (kg)", ylab = "HEIGHT (cm)") - - -lm(height ~ bodymass) - - -abline(98.0054, 0.9528) - -abline(lm(height ~ bodymass)) -