The fread() function from data.table package used to read large data files in R.

The following method shows how you can do it with syntax.

Method: Use fread() Function

library(data.table)

fread("file_name")

The following example shows how to use fread() function in R.

Use fread() Function From data.table Package

Let’s see how we can use fread() function to read data from CSV file:

# Import library
library(data.table)

# Import CSV file
data <- fread("product.csv")

# Display imported data
print(data)

Output:

   Product data Count
         <char> <int>
1:     Cylinder    12
2:       Sensor     6
3:      Display     2
4:      Monitor     1

As the output shows data from product.csv file.