Read contents of a CSV File in R Programming – read.csv() Function
read.csv() function in R Language is used to read “comma separated value” files. It imports data in the form of a data frame.
read.csv(file, header, sep, dec)
file: the path to the file containing the data to be imported into R.
header: logical value. If TRUE, read.csv() assumes that your file has a header row, so row 1 is the name of each column. If that’s not the case, you can add the argument header = FALSE.
sep: the field separator character
dec: the character used in the file for decimal points.
Example 1: Reading file from same folder
V1 V2 V3 1 100 AB ab 2 200 CD cd 3 300 EF ef 4 400 GH gh 5 500 IJ ij
Example 2: Reading file from different directory
X V1 V2 V3 1 1 100 a1 b1 2 2 200 a2 b2 3 3 300 a3 b3