Enhancing a data.frame with a data.table
When you process a dataset that is a Gigabyte or larger in size, you may find that a data.frame
is rather inefficient. To address this issue, you can use the enhanced extension of data.frame
—data.table
. In this recipe, we will show how to create a data.table
in R.
Getting ready
Download the purchase_view.tab
and purchase_order.tab
datasets from the following GitHub links, respectively:
How to do it…
Perform the following steps to create a data.table
:
First, install and load the
data.table
package using the following commands:> install.packages("data.table") > library(data.table)
Next, we can create an R data frame using
read.table
:> purchase <- read.table("purchase_view.tab", header=TRUE, sep='\t') [1] "data.frame" > dim(purchase) [1] 1191486 4 > order <- read.table("purchase_order...