Author: Zhanbii Kadyrkulov
data()
mydata <- force(iris)
head(mydata)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
Unit of observation: One flower
Sample size: 150 flowers
-Sepal.Length: it is the measurement of small, leaf-shaped, green-coloured and outermost part of the flower length in cm
-Sepal.Width: it is the measurement of small, leaf-shaped, green-coloured and outermost part of the flower width in cm
-Petal.Length: it is the measurement of the second whorl of the flower lenght in cm
-Petal.Width: it is the measurement of the second whorl of the flower width in cm
-Species: it is the name of the flower type
Source: Fisher, R. A. (1936) The use of multiple measurements in taxonomic problems. Annals of Eugenics, 7, Part II, 179–188.
The data were collected by Anderson, Edgar (1935). The irises of the Gaspe Peninsula, Bulletin of the American Iris Society, 59, 2–5.
mydata$SpeciesF <- factor(mydata$Species,
levels = c("setosa", "versicolor", "virginica"),
labels = c("Flower1", "Flower2", "Flower3"))
Writing this code, I changed categorical variable specie to factor
#install.packages(psych)
library(psych)
describeBy(mydata$Sepal.Length , group = mydata$SpeciesF)
##
## Descriptive statistics by group
## group: Flower1
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 50 5.01 0.35 5 5 0.3 4.3 5.8 1.5 0.11 -0.45 0.05
## ------------------------------------------------------------
## group: Flower2
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 50 5.94 0.52 5.9 5.94 0.52 4.9 7 2.1 0.1 -0.69 0.07
## ------------------------------------------------------------
## group: Flower3
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 50 6.59 0.64 6.5 6.57 0.59 4.9 7.9 3 0.11 -0.2 0.09
We can see that using the describeBy command we can say that 50% (median) of of virginica species had sepal lenght less or equal 6.5 cm and the other half had more than 6.5.
summary(mydata[ ,c(-5, -6)])
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
## Median :5.800 Median :3.000 Median :4.350 Median :1.300
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
We can say that 75% (3rd quartile) of all species had sepal width equal to 3.3cm. Another thing to outline is that the maximum petal lenght of all species was 6.9cm. Also the petal width of all species was equal to 0.1cm.
boxplot(mydata[ , c(-5,-6)])
According to this boxplot we can see that the biggest sepal length of
flower is 7.9cm because we can see that the highest line in the boxplot
is somewhere around 8. The bold line in each box represents the median
of all of variables, meaning 50% of each statistics. The circles on the
sepal width mean that there are some outstanders that don’t belong to
the other units. The lowest line mean the minimum of the variable.
Bottom edge of these gray boxes means 1st quartile. Upper edge means 3rd
quartile.