On Oct 10, 2011, at 7:45 AM, Spartina wrote:
> Hello all,
>
> how do I import a Fortran file (f3.1) into one column in R? I've
> tried this
> (I'm a total beginner as you can see):
>
>>
FortranData<-read.fwf("C:\\Users\\format3_1.txt",rep(3,20))
> Warning message:
> In readLines(file, n = thisblock) :
> incomplete final line found on 'C:\Users\format3_1.txt'
>> FortranData
> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17
> V18
> V19 V20
> 1 2.2 3.3 4.2 2.1 3.4 2.3 2.3 4.2 2.1 3.4 2.3 2.3 4.2 2.1 3.4 2.3
> 2.3 4.2
> 2.1 3.4
>
> As you can see, each datum gets imported into a separate column,
> whereas I'd
> like to have everything stored under V1.
Have you considered transposing the result? If this is a multiple line
file that you wnat to "straighten out" completely you could first
convert to matrix, transpose, and then wrap in c() to get a vector of
values.
> I'm also unsure as to what the
> error message means.
It's not an error. It's only a warning. It just menans there is not
end of line marker on the last line.
>
> Thanks in advance for your help!
>
> L?a
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Importing-from-Fortan-tp3889947p3889947.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
David Winsemius, MD
West Hartford, CT