DATA VISUALIZATION AND PLOTTING TECHNIQUES
AIM:
To explore the Iris dataset with R
PROCEDURE:
1. data(iris)
2. head(iris, 4)
3. tail(iris)
4. The dimensions of the dataframe
dim(iris)
5. The names of the columns
names(iris)
6. The attributes of the dataframe
attributes(iris)
7. Finally, if you want the descriptive statistics summary
summary(iris)
8. Indexing the first 5 rows
iris[1:5,]
9. Indexing the first 4 columns
iris[,1:4]
10. If you want to explore the first 10 rows of a particular column, in this case, Sepal length
iris[1:10, "Sepal.Length"]
Basic Visualizations with Base R
The plot () function is the generic function for plotting R objects.
plot(iris2)
Histogram with hist() function:
sepal_length<-iris2$sepal.length
hist(sepal_length)
hist(sepal_length, main="Histogram of Sepal Length", xlab="Sepal Length", xlim=c(4,8),
col="blue", freq=FALSE
sepal_width<-iris2$sepal.width
hist(sepal_width, main="Histogram of Sepal Width", xlab="Sepal Width", xlim=c(2,5),
col="darkorchid", freq=FALSE)