Import CSV file into R
Method 1: Using read.csv() methods.
Here we will import csv file using the read.csv() method in R.
Syntax: read.csv(path, header = TRUE, sep = “,”)
Arguments :
- path : The path of the file to be imported
- header : By default : TRUE . Indicator of whether to import column headings.
- sep = “,” : The separator for the values in each row.
R
# specifying the path path <- "/gfg.csv" # reading contents of csv file content <- read.csv (path) # contents of the csv file print (content) |
Output:
ID Name Post Age
1 5 H CA 67
2 6 K SDE 39
3 7 Z Admin 28
How To Import Data from a File in R Programming
The collection of facts is known as data. Data can be in different forms. To analyze data using R programming Language, data should be first imported in R which can be in different formats like txt, CSV, or any other delimiter-separated files. After importing data then manipulate, analyze, and report it.
Contact Us