Importing Data from a delimited file
R has a function read.delim() to read the delimited files into the list. The file is by default separated by a tab which is represented by sep=””, that separated can be a comma(, ), dollar symbol($), etc.
Syntax: read.delim(“file_name.txt”, sep=””, header=TRUE)
R
x <- read.delim ( "D://Data//myfile.csv" , sep= "|" , header= TRUE ) # print x print (x) # print type of x typeof (x) |
Output:
X.V1.V2.V3
1 1, 100, a1, b1
2 2, 200, a2, b2
3 3, 300, a3, b3
[1] "list
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