TC Technology Knowledge Base

Import data into R- .txt files in R-Studio

Updated on

1. Use read.table for any files end with .txt.

1.1. For Mac: menu<-read.table("/Users/joeystanley/Desktop/menu.csv", sep="\t", header=TRUE)

1.2. For Windows/PC: menu<-read.table("C:\\Users\\joeystanley\\Desktop\\menu.txt", sep="\t", header=TRUE)

2. As an additional argument, you may need to specify that the cells of your table are separated by tabs.

2.1. Add the sep="\t" argument (\t is "computer-talk" for tab).

2.2. Add header=TRUE argument to the command to indicate the first row of your file might contain the names of the columns.

Previous Article Import data in R .CSV Files into R-Studio
Next Article Get Data into R Excel Files in R-Studio