Merging and Importing Data Additionalmaterial
Merging and Importing Data Additionalmaterial
## [1] 150 5
We can also use nrow and ncol to get the number of rows and number of columns, respectively.
nrow(iris)
## [1] 150
ncol(iris)
## [1] 5
Thus, iris has 150 rows and 2 columns, which can also be verified by using str function. It also returns
many useful pieces of information, including the above information and the types of data for each column.
str(iris)
1
Figure 1: Installing readxl and Rcpp
We use head to obtain the first n observations and tail to obtain the last n observations; by default, n = 6.
These are good commands for obtaining an intuitive idea of what the data look like without revealing the
entire dataset, which could have millions of rows and thousands of columns (Cai 2013).
head(iris, 2)
References
Andrew Shaughnessy, Elizabeth Hasenmueller, Christopher Prener. 2018. “Exploring Data in R.” https:
//cran.r-project.org/web/packages/driftR/vignettes/ExploringData.html.
Cai, Eric. 2013. “Exploratory Data Analysis: Useful R Functions for Exploring a Data Frame.” https://
chemicalstatistician.wordpress.com/2013/08/19/exploratory-data-analysis-useful-r-functions-for-exploring-a-data-frame/.
Overflow, Stack. 2013. “Unable to install R package in Ubuntu 11.04.” https://stackoverflow.com/questions/
7765429/unable-to-install-r-package-in-ubuntu-11-04.