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.
Maybe you could manually edit the first line (change , to " " and insert a line break) and then try again?
Use
read.csv
instead ofread.table
and then addskip=1, header=FALSE
to the arguments toread.csv
.While the data is ill-formed it still can be parsed given the following assumptions:
numeric()
)The following is code that parses the provided sample data as if it were read in from a text file called
data.txt
:producing the following output: