Outline of the course

Chapter 1. What is Statistics

Chapter 1. What is Statistics

Chapter 1. Population and Sample

Chapter 1. Type of Measurements (data)

Categorical data and Numerical data

Chapter 1. Type of Measurements (data)

Level of measurements

Data never sleep

Characterizing a set of measurements

Table and Graphical methods

## Characterizing a set of measurements

Example

## Characterizing a set of measurements

Example

We can summarize their frequencies and relative frequencies in a frequency table

  1. Input data
# Input computer data

com.stoppage <- c(1,3,1,1,0,1,0,1,1,0,2,2,0,0,0,1,2,1,2,0,0,1,6,4,3,3,1,2,4,0)
  1. Summarize frequencies in a frequency table
#summary(com.stoppage)
com.freq <- table(factor(com.stoppage, levels = min(com.stoppage):max(com.stoppage)))
#hist(com.stoppage)

com.freq
## 
##  0  1  2  3  4  5  6 
##  9 10  5  3  2  0  1
  1. Construct frequency histogram
  • Base plot
barplot(com.freq)

  • ggplot
df1 <- as.data.frame(com.freq)
library(ggplot2)
ggplot(data=df1,aes(x=Var1,y=Freq))+
  geom_bar(stat="identity", fill="steelblue")+
  geom_text(aes(label=Freq), vjust=-0.3, size=3.5)

vals <- factor(com.stoppage)
table(vals)
## vals
##  0  1  2  3  4  6 
##  9 10  5  3  2  1
typeof(vals)
## [1] "integer"
dim(table(vals))
## [1] 6
df <- as.data.frame(table(vals))
df
##   vals Freq
## 1    0    9
## 2    1   10
## 3    2    5
## 4    3    3
## 5    4    2
## 6    6    1
library(ggplot2)
ggplot(data=df,aes(x=vals,y=Freq))+
  geom_bar(stat="identity", fill="steelblue")+
  geom_text(aes(label=Freq), vjust=-0.3, size=3.5)

More options in barplot output link