Alex Woolford
Alex Woolford

Reputation: 4563

import a file that's delimited by special characters into an R dataframe

I have a file that's delimited by a special character (ctl-A, which has an ASCII code of 1, 0x01 in hex) that I'd like to import into an R dataframe. In vi it looks like this:

control+A delimited file

How do I import this file?

Upvotes: 1

Views: 421

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 269606

That character can be used in sep=

> Lines <- "abc\1def\nABC\1DEF"
> read.table(text = Lines, sep = "\1")
   V1  V2
1 abc def
2 ABC DEF

Upvotes: 1

Related Questions