-4

I have a text file to import the data from, and I want to read it in 3 columns, but the data only imports one. The file is pretty big, and there are no . or , involved. Some of the data are made from more than one word in succession, so I can't separate them by " ".

I have been using:

a <- read.table("filename.txt", sep = "\t")

The data comes back naturally in rows, but with only one column. This is how the data looks like: !http://prntscr.com/f4c4a6

  • 4
    Welcome to Stack Overflow! We can't really answer your question without more information about the data. Please provide the first few lines of your data as an example. To see more fully what you should provide, please read the section of the help files on [Asking a Question](http://stackoverflow.com/help/how-to-ask) – G5W May 03 '17 at 17:09
  • do you use R studio –  May 03 '17 at 17:30
  • yes i ve been using r studio,the general format the file has goes like : CODE SENTENCE SENTENCE – Giorgos Mihalakis May 04 '17 at 12:32
  • So, what is the rule to distinguish were one column ends and the other starts? How do _you_ recognize that the data consists of three columns? Or, are the data supplied in a fixed-width format? Please, can you [edit] your question and show the first few lines of the file? – Uwe May 04 '17 at 17:07
  • Try to use fread from the data.table package instead of read.table : `a <- fread(filename.txt")` – Rhesous May 05 '17 at 08:15

1 Answers1

0

As it is in coments above, try:

library(data.table)
data <- fread("data.txt", select = c(1:3))
Adamm
  • 2,150
  • 22
  • 30