Re: [R] reading in file with different row length

2010-05-06 Thread David Winsemius
On May 6, 2010, at 12:10 PM, Muhammad Rahiz wrote: Hi all, I have a file, say, test.txt, which contains the following information. I'm trying to read in the file and specifying the missing values as NA so that each column has the same number of rows. I've tried all sorts of manipulation

Re: [R] reading in file with different row length

2010-05-06 Thread Muhammad Rahiz
Thanks Jim but I've tried the method but it didnt work. Space separates the columns so when I pass x <- read.csv("test.txt",sep=",") it reads and prints ok but gives the wrong dim x <- dim(x) [1] 9 1 when the dim(x) should be 9 3 Muhammad jim holtman wrote: What is the delimiter be

Re: [R] reading in file with different row length

2010-05-06 Thread jim holtman
What is the delimiter between the columns? If it is a tab/comma, then read.table will handle it. If as your example shows, the missing data is just a space, then you will have to have some code that cleans up the data, For example a single space is replaced by a single comma, two spaces replaced

[R] reading in file with different row length

2010-05-06 Thread Muhammad Rahiz
Hi all, I have a file, say, test.txt, which contains the following information. I'm trying to read in the file and specifying the missing values as NA so that each column has the same number of rows. I've tried all sorts of manipulation but to no avail. r1 r2 r3 1 3 2 3 3 2 3 4 2 3 5 2 3