On Fri, May 27, 2016 at 12:56 PM, Steven Yen <sye...@gmail.com> wrote:
> Dear fellow R users: > I am reading a data (ascii) file with fortran fixed format, containing > multiple records. R does not recognize fortran's record break (a slash). > I tried to do the following but it does not work. Help appreciated. > > 60 FORMAT(1X,F6.0,5F8.6/1X,5F8.4,F10.6/1X,2F6.0,3E15.9,F8.0,F5.2,F5.3 > * /1X,F7.0,2E15.9,F9.4,F5.3) > > mydata<-read.fortran("G:/Journals/Disk1/12_restat_95/estimate/GROUPD.DAT", > > c("1X","F6.0","5F8.6"/"1X","5F8.4","F10.6" > /"1X","2F6.0","3E15.9","F8.0","F5.2","F5.3" > /"1X","F7.0","2E15.9","F9.4","F5.3"), > > col.names=c("year","w1","w2","w3","w4","w5","w6","v1","v2","v3", > "v4","v5","v6","z","chyes","chno","ec","vc","cvc", > "pop","ahs","fah","tnh","eq","vq","ups","zm1 ")) > Did you see this from ?read.fortran <quote> For a single-line record, ‘format’ should be a character vector. For a multiline record it should be a list with a character vector for each line. </quote> I think (not sure) you need: mydata<-read.frotran("G:/Journals/Disk1/12_restat_95/estimate/GROUPD.DAT", list(c("1X","F6.0","5F8.6"),c("1X","5F8.4","F10.6"),c("1X","2F6.0","3E15.9","F8.0","F5.2","F5.3"),c("1X","F7.0","2E15.9","F9.4","F5.3")). col.names=c("year","w1","w2","w3","w4","w5","w6","v1","v2","v3", "v4","v5","v6","z","chyes","chno","ec","vc","cvc", "pop","ahs","fah","tnh","eq","vq","ups","zm1 ")) -- The unfacts, did we have them, are too imprecisely few to warrant our certitude. Maranatha! <>< John McKown [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.