Reading and writing files with data.table

For reading and writing filesfor example, CSV filesthere is no other function as fast and efficient as fread and fwrite in R as of today. Let us first see how to read and write CSV files as shown as follows: 

# fwrite: Writing csv files 
# Check the help file for fwrite as it includes numerous options that can be passed to the fwrite function. 
 
?fwrite  

The simplest way to use fwrite is to pass the name of the data.table or data.frame as the first argument followed by the name of the file you'd like to create, as follows:

fwrite(dstate, file="dstate.csv") # Save data.table dstate into the csv file dstate.csv 
 
# Note that we can change the separator using the sep argument (eg., sep="|) 
 
# To read back the file, simply use fread(filename) 
fread("dstate.csv") 
 
# Similar to fwrite, the function fread can accept several other helpful arguments as can be seen from ?fread 
 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.203.96