Explain with an example how to view the first few rows or the last few rows of a dataset in R.
To do this we have to select a dataframe for selecting rows and columns. A data frame is a structure having 2 dimensions which contains data in the form of rows and columns. It can be spreadsheet data and can be represented in the form of tables or dictionaries of series.
In R, let us read a built in dataset which is iris dataset.It contains the following attributes
Based on the following attributes are considered which are the Species.
Now it contains about 150 rows.To view only the first 5 rows we can choose
So the above 5 rows contain the species setosa.Let us see the below 5 rows and look into the outcome
To view the last 5 rows we can choose
The above rows represent the last rows which belong to the species virginica.