Chapter 17 Univariate

17.1 Data

d<-read.csv("https://tinyurl.com/aqm-data/mussels.csv")
dt(d)

17.2 Data summaries for individual variables

Change the name of the variable to match a numerical variable in your own data set. The command removes NAs just in case you have them

summary(d$Lshell,na.rm=TRUE)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    61.9    97.0   106.9   106.8   118.7   132.6

17.3 Individual statistics for a single variable

Mean, median, standard deviation and variance.

mean(d$Lshell, na.rm=TRUE)
## [1] 106.835
median(d$Lshell, na.rm=TRUE)
## [1] 106.9
sd(d$Lshell, na.rm=TRUE)
## [1] 14.84384
var(d$Lshell, na.rm=TRUE)
## [1] 220.3397

17.4 Simple boxplot of one variable

Useful for your own quick visualisation.

boxplot(d$Lshell)

17.5 Simple histogram of one variable

Useful for your own quick visualisation.

hist(d$Lshell)

17.6 Neater histogram of one variable

This uses ggplot. Change the bin width if you want to use this.

g0<-ggplot(d,aes(x=d$Lshell))
g0+geom_histogram(color="grey",binwidth = 5)