Taking this file as an example, I’m trying to read the data in a data.frame. From the doc (pdf file, table 1), it follows some fortran convention. I tried the following with little success:
dir <- "Uncompressed-files/"
file <- "01_hit09.par"
delim <- c("I2", "I1", "F12.6", "E10.3", "E10.3", "F5.4", "F5.4",
"F10.4", "F4.2", "F8.6", "A15", "A15", "A15", "A15", "6I1", "6I2",
"A1", "F7.1", "F7.1")
test <- read.fortran(paste0(dir, file), delim)
test <- read.fwf(paste0(dir, file),
c(2, 1, 12, 10, 10, 5, 5, 10, 4, 8,
15, 15, 15, 15, 6, 12, 1, 7, 7))
Any tips to specify the correct format?
According to
?read.fortran:"E"is not a supported format.the decimal ‘d’ places to the left, even if it is explicitly
specified in the input file.”
So change
"E"to"F"and remove all the explicit decimal formats:UPDATE: Or specify the widths correctly and use
read.fwf: