One way is to use 'readLines' to read in the file, change the ';' to '\n', write the file out and then read it back in:
> x <- readChar('/temp/test.txt', 1e6) > print(x) [1] "1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6;1,2,3,4,5,6\r\n" > x <- gsub(';', '\n', x) > writeChar(x, '/temp/testNew.txt') > # now read in the data > x.df <- read.table('/temp/testNew.txt', sep = ',') > x.df V1 V2 V3 V4 V5 V6 1 1 2 3 4 5 6 2 1 2 3 4 5 6 3 1 2 3 4 5 6 4 1 2 3 4 5 6 5 1 2 3 4 5 6 6 1 2 3 4 5 6 7 1 2 3 4 5 6 8 1 2 3 4 5 6 9 1 2 3 4 5 6 10 1 2 3 4 5 6 11 1 2 3 4 5 6 12 1 2 3 4 5 6 On Fri, Dec 21, 2012 at 12:39 PM, murfs <jm9...@my.bristol.ac.uk> wrote: > I'm trying to import a matrix created in PARI/GP into R but am having > problems. > The data in the text file has entries separated by commas but the rows > themselves are separated by semicolons rathen than being on a new line. Is > there a way to get R to recognise that ";" means start a new row ? > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Difficulty-importing-data-from-PARI-GP-tp4653736.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.