I have a file (prf003.tre) generated from some old proprietary software, that I am trying to edit in R. It is structured as such:
0001 116.00 1BF 19.2 0.0 5500 0
0001 216.00 1BF 19.2 0.0 5500 0
0001 316.00 1BF 19.2 0.0 5500 0
0001 416.00 1BF 19.2 0.0 5500 0
0001 516.00 1BF 19.2 0.0 5500 0
0001 616.00 1BF 19.2 0.0 5500 0
0001 716.00 1BF 19.2 0.0 5500 0
The goal is to be able to import the file, modify the values in column 2 to read
prf003[, 2]<- seq.int(nrow(prf003))
and then re-export the file.
(Between each cell are about 10-20 spaces depending on what column. Unfortunately copying this into stackoverflow does not make it appear this way, so I pasted it as code, hope that is okay, sorry I am newb. I need to preserve the integrity of the spacing.)
I tried to import into R, trying both read.table and readLines. read.table does not preserve the spacing, however I am unable to modify column 2 using readLines, given that it reads it as one column. Any suggestions? Perhaps there is a setting in read.table that I am not aware of, but searching has brought up nothing.
edit: read.Table also drops the 0's at my first column, any tips on how to preserve the "0001" would be helpful.
read.table(data, colClasses = "character")
will prevent the leading zeros from being dropped. – Mako212