There are five common structures in R namely:
The vector can be categorized up to six levels namely
# Overview of descriptive statistics
y1<-c(1.13,1.11,0.629,0.616,0.265,0.320,
0.849,0.378,0.056,0.044,0.241,0.221,
0.110,0.190,0.151,0.049)
y2<-c(T,T,T,F,F,F,T,T,T,F,F,F,T,T,T,F)
y3<-1:16
y4<-c("cabdi","ali","cawo","ali","ayan","ali","ali",
"ayan","awo","omar","abdi","ali","awo","ayan","elmi","awsalawad")
data<-data.frame(y1,y2,y3,y4)
write.csv(data,"~/jibril.csv")
# Data Transformation
y5<-c("n","n","p","p","p","s","s","s","s","s","u","u","u","u","u","u")
y6<-ordered(y5)
y6
## [1] n n p p p s s s s s u u u u u u
## Levels: n < p < s < u
y7<-as.factor(y5)
y7
## [1] n n p p p s s s s s u u u u u u
## Levels: n p s u
y8<-as.numeric(y3)
# Descriptive Statistics
# - Locigal = Binary
# - Numerical = Countinuous
# - Integer = count
# - Character = Categorical
# - Factor and Ordinal = Arise from character
# 1 Vector = v<-()
# 2 Mater
mean(y1)
## [1] 0.3974375
median(y1)
## [1] 0.253
mode(y1)
## [1] "numeric"
sd(y1)
## [1] 0.3631802
var(y1)
## [1] 0.1318999
max(y1)
## [1] 1.13
min(y1)
## [1] 0.044
range(y1)
## [1] 0.044 1.130
# Descriptive Packages
# 1 Psych
# 2 Envstats
# 3 Adequacy Model
# 4 Moments
library(AdequacyModel)
windows()
descriptive(y1)
## $mean
## [1] 0.39744
##
## $median
## [1] 0.253
##
## $mode
## [1] 0.1
##
## $variance
## [1] 0.1319
##
## $Skewness
## [1] 0.98292
##
## $Kurtosis
## [1] -0.34013
##
## $minimum
## [1] 0.044
##
## $maximum
## [1] 1.13
##
## $n
## [1] 16
library(psych)
describe(y1)
# Summarize Descriptive Statistics using "EnvStats"
library(EnvStats)
##
## Attaching package: 'EnvStats'
## The following objects are masked from 'package:stats':
##
## predict, predict.lm
summaryFull(y1)
## y1
## N 16
## Mean 0.3974
## Median 0.253
## 10% Trimmed Mean 0.3704
## Geometric Mean 0.2522
## Skew 1.088
## Kurtosis 0.01794
## Min 0.044
## Max 1.13
## Range 1.086
## 1st Quartile 0.1407
## 3rd Quartile 0.6192
## Standard Deviation 0.3632
## Geometric Standard Deviation 2.884
## Interquartile Range 0.4785
## Median Absolute Deviation 0.252
## Coefficient of Variation 0.9138
# Data Visualization (Numerical Data)
windows()
hist(y1)
windows()
hist(y1, col="green",main="final Exam Score",
xlab="Mathmatics", ylab="Grades")
windows()
plot(density(y1))
windows()
plot(density(y1), col="blue",main="Final Exam Score",
xlab="Mathmatics", ylab="Grades")
windows()
plot(density(y1),col="red",border = "navy",
main="Final Exam Score", xlab="Mathmatics", ylab="Grades")
## Warning in plot.window(...): "border" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "border" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "border" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "border" is not a
## graphical parameter
## Warning in box(...): "border" is not a graphical parameter
## Warning in title(...): "border" is not a graphical parameter
polygon(density(y1),col="red",border = "navy",
main="Final Exam Score", xlab="Mathmatics", ylab="Grades")
windows()
boxplot(y1,col="cyan",border = "navy",
main="Final Exam Score", xlab="Mathmatics", ylab="Grades")
library(vioplot)
## Loading required package: sm
## Package 'sm', version 2.2-5.7: type help(sm) for summary information
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
windows()
vioplot(y1,col="magenta",border = "green",
main="Final Exam Score", xlab="Mathmatics", ylab="Grades")
library(beanplot)
windows()
beanplot(y1, col="lightblue",border = "yellow",
main="Final Exam Score", xlab="Mathmatics", ylab="Grades")
## log="y" selected
library(beeswarm)
windows()
beeswarm(y1, col="navy",border = "yellow",
main="Final Exam Score", xlab="Mathmatics", ylab="Grades")
## Warning in plot.window(...): "border" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "border" is not a graphical parameter
## Warning in title(...): "border" is not a graphical parameter
## Warning in axis(2, ...): "border" is not a graphical parameter
## Warning in axis(1, at = at, labels = labels, tick = FALSE, ...): "border" is
## not a graphical parameter
## Warning in box(...): "border" is not a graphical parameter