There are four common structures in R namely;
The vector can be categorized upto 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("abid","ali","ali","ali","awo","awo","ali","omer","ali","awo","ayan","ali",
"omar","ali","ali","ayan")
# above variables are explained by type of the data
# Y1 is num, Y2 logi, Y3 is int, and Y3 is chr
data<-data.frame(y1,y2,y3,y4)
# the above code is used to combine all that different dats into one data.
write.csv(data,"~/aar.csv")
# the above code is to change data into csv
# To save all your work just go to file and select save as.
class(y1)
## [1] "numeric"
# Data Transformation
y5<- c("p","p","p","p","p","s","s","s","s","s","u","u","u","u","u","u")
y6<- ordered(y5)
y6
## [1] p p p p p s s s s s u u u u u u
## Levels: p < s < u
y7<-as.factor(y5)
y7
## [1] p p p p p s s s s s u u u u u u
## Levels: p s u
y8<-as.numeric(y3)
# Descriptive statistics
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
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)
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()
windows()
hist(y1, col="green", main ="Final Exam Scores", xlab= "Mathematics",
ylab = "Grades")
windows()
plot(density(y1))
windows()
plot(density(y1),col="cyan", main ="Final Exam Scores", xlab= "Mathematics",
ylab = "Grades")
windows()
plot(density(y1),col="black", border = "red", main ="Final Exam Scores", xlab= "Mathematics",
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="black", border = "red", main ="Final Exam Scores", xlab= "Mathematics",
ylab = "Grades")
windows()
boxplot(y1, col="cyan", main ="Final Exam Scores", xlab= "Mathematics",
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="cyan", main ="Final Exam Scores", xlab= "Mathematics",
ylab = "Grades")
library(beanplot)
windows()
beanplot(y1, col="lightblue", main ="Final Exam Scores", xlab= "Mathematics",
ylab = "Grades")
## log="y" selected
library(beeswarm)
windows()
beeswarm(y1, col="cyan", main ="Final Exam Scores", xlab= "Mathematics",
ylab = "Grades")