I’ve decided to hold a five week introductory statistics and R course. Here, I am sharing the slide deck and the code. The video will go up on our YouTube Data Science Virtual Chapter channel, which is accessible from here.
In the first week, we talked about the relationship between statistics and data visualisation, and how it is extremely useful to have a good grounding in both topics. The slides are here, followed by the code:
The R code can be copied and pasted into your RStudio file:
# Loads sample datasets
# Let’s look at the data
# This command tells you the metadata. What does R see, when it sees ‘iris’?
# What are the attributes?
# This gives us more information.
# Let’s see more of the data
# A data frame has columns which can have different types.
# The column names and types constitute the schema.
# how do we know what is in our data frame?
# Column Names
# how can we see data in one of the columns?
# or we could also use iris[,3] to get the same column data.
# of course, we want to visualise the data.
# Let’s do a simple scatter plot.
# How can we see the first five rows?
# how can we see the Petal Length of the first 5 rows?
# This shows us some of the descriptive statistics of each variable
# Let’s have some dataviz fun!
plot(iris$Petal.Length, iris$Petal.Width, main=”Anderson’s Iris Data”)
# You can now see the plot appear in the right hand side frame of RStudio.
# we can make it slightly more interesting
plot(iris$Petal.Length, iris$Petal.Width, pch=23, bg=c(“orange”, “blue”, “green”) [unclass(iris$Species)], main=”Anderson’s Iris Data”)
# we can make it even more interesting
pairs(iris[1:4], main = “Anderson’s Iris Data”, pch = 23, bg = c(“orange”, “green”, “blue”)[unclass(iris$Species)])
# pie charts!
# ooh, 3D!
scatterplot3d(iris$Petal.Width, iris$Sepal.Length, iris$Sepal.Width)
# ooh, even more 3D!
plot3d(iris$Petal.Width, iris$Sepal.Length, iris$Sepal.Width)
#Save your work!
savehistory(“~/Topic 1 Getting familiar with R A.Rhistory”)