Data Science Study Material
Added on 2023-01-19
18 Pages2019 Words80 Views
Data science 1
by [Student Name]
Data Science
Tutor: [Tutor Name]
[Institutional Affliliation]
[Department]
[Date]
by [Student Name]
Data Science
Tutor: [Tutor Name]
[Institutional Affliliation]
[Department]
[Date]
Data science 2
Q1
Iris dataset contains data about three iris flower species setosa, virginica, and versicolor. The
three species have four measured features on each: sepal length, sepal width, petal length, and
petal width. The dataset consists of 50 samples from each of the three species (Alvarez-
Castillo et al., 2016).
library(datasets)
This code loads the package datasets, attaches it on the search list and makes functions and
data contained in the package available.
str(iris)
The code call iris data from package dataset.
View(iris)
The code view() help to view the dataset iris in a sheet-like in excel. There are 150
observations and 5 variables that is sepal length, sepal width, petal length, petal width, and
species.
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
Q1
Iris dataset contains data about three iris flower species setosa, virginica, and versicolor. The
three species have four measured features on each: sepal length, sepal width, petal length, and
petal width. The dataset consists of 50 samples from each of the three species (Alvarez-
Castillo et al., 2016).
library(datasets)
This code loads the package datasets, attaches it on the search list and makes functions and
data contained in the package available.
str(iris)
The code call iris data from package dataset.
View(iris)
The code view() help to view the dataset iris in a sheet-like in excel. There are 150
observations and 5 variables that is sepal length, sepal width, petal length, petal width, and
species.
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
Data science 3
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
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
7 4.6 3.4 1.4 0.3 setosa
8 5.0 3.4 1.5 0.2 setosa
Q2
To view the first ten observation of each subset of the flower species we need to extract
the subsets first using the codes :
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
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
7 4.6 3.4 1.4 0.3 setosa
8 5.0 3.4 1.5 0.2 setosa
Q2
To view the first ten observation of each subset of the flower species we need to extract
the subsets first using the codes :
Data science 4
virginica=filter(iris, Species=="virginica")
virginica
head(virginica,10)
head(virginica,10)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 6.3 3.3 6.0 2.5 virginica
2 5.8 2.7 5.1 1.9 virginica
3 7.1 3.0 5.9 2.1 virginica
4 6.3 2.9 5.6 1.8 virginica
5 6.5 3.0 5.8 2.2 virginica
6 7.6 3.0 6.6 2.1 virginica
7 4.9 2.5 4.5 1.7 virginica
8 7.3 2.9 6.3 1.8 virginica
9 6.7 2.5 5.8 1.8 virginica
10 7.2 3.6 6.1 2.5 virginica
setosa=filter(iris, Species=="setosa")
setosa
head(setosa,10)
head(setosa,10)
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
virginica=filter(iris, Species=="virginica")
virginica
head(virginica,10)
head(virginica,10)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 6.3 3.3 6.0 2.5 virginica
2 5.8 2.7 5.1 1.9 virginica
3 7.1 3.0 5.9 2.1 virginica
4 6.3 2.9 5.6 1.8 virginica
5 6.5 3.0 5.8 2.2 virginica
6 7.6 3.0 6.6 2.1 virginica
7 4.9 2.5 4.5 1.7 virginica
8 7.3 2.9 6.3 1.8 virginica
9 6.7 2.5 5.8 1.8 virginica
10 7.2 3.6 6.1 2.5 virginica
setosa=filter(iris, Species=="setosa")
setosa
head(setosa,10)
head(setosa,10)
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
End of preview
Want to access all the pages? Upload your documents or become a member.
Related Documents
R Code for Dataset Iris Analysislg...
|20
|2984
|67
Australia's First Recession in Nearly 30 Yearslg...
|12
|2656
|51