The read.delim() function in R is used to read data from a delimited text file into a data frame.

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

Method 1: Use read.delim() Function

read.delim(file, header=TRUE, sep='\t')

The following example shows how to use read.delim() function in R to read data from text file.

Using read.delim() Function

Let’s see how to use read.delim() function in R:

# Read in tab-delimited text file
df_ <- read.delim('sample.txt')

# Print data
print(df_)

Output:

Machine_name Pressure Temperature
1            A    78.20          31
2            B    71.70          35
3            C    80.21          36
4            D    83.12          36
5            E    82.56          38
6            F    79.50          32

Here the output shows data from sample.txt file which read using read.delim() function.