tags:

views:

171

answers:

4

I have a text file that I'd like to import into R. Problem is, the file looks like this:

x1,x2,x3,x4,x5,x6,x7,x8,x9,10,x11 1953.00 7.40000 159565. 16.6680 8883.00
47.2000 26.7000 16.8000 37.7000 29.7000
19.4000
1954.00 7.80000 162391. 17.0290 8685.00
46.5000 22.7000 18.0000 36.8000 29.7000
20.0000

and so on.

I tried > data <- read.table("clipboard", header=TRUE) but that didn't work.

A: 

Maybe you could manually edit the first line (change , to " " and insert a line break) and then try again?

Karsten W.
The read.csv command sort of worked, but instead of returning all variables values for an observation on one line (which is what I want), variable values for each observation spill over two lines (which is what I don't want). tricky
Stu
so it seems one observation is on 3 lines. I don't think this can be handled by read.csv. Maybe you could try ?readLines, and then run a for loop to concatenate the data for each observation?
Karsten W.
A: 

Use read.csv instead of read.table and then add skip=1, header=FALSE to the arguments to read.csv.

Alex Brown
A: 

I'm not sure, but take a look at read.fwf type ?read.fwf

regards Manoel

Manoel Galdino
A: 

The formatting of the data seems inconsistent. You may have to format the data so that everything is separated by a common separator.

Jesse