weird results in your data at the end or even things like an
integer column being considered to be character.
-Original Message-
From: R-help On Behalf Of javad bayat
Sent: Thursday, September 22, 2022 6:35 AM
To: Rui Barradas
Cc: R-help@r-project.org
Subject: Re: [R] Write text file
Hello,
Maybe the following solves the problem.
I hope it does if the mailman footer is no longer there.
# this path depends on the OP's system
path <- "~/Temp"
fl <- list.files(path, pattern = "Air.txt", full.names = TRUE)
# read the file as text
txt <- readLines(fl)
# find lines starting wit
These 2 lines were at the end of the text file, which I have attached but I
had removed them to read the text file in R.
Just like the first 8 line that start with asterisk (*).
On Thu, 22 Sep 2022, 12:21 Rui Barradas, wrote:
> Hello,
>
> Are those lines at the begining of the file?
>
> Rui
Hello,
Are those lines at the begining of the file?
Rui Barradas
Às 06:44 de 22/09/2022, javad bayat escreveu:
Dear all; Many thanks for your useful comments and codes.
I tried both Rui's and Jim's codes.
Jim's codes gave an error as below:
"Error in substr(inputline, 1, begincol3 - 1) :
ob
Dear all; Many thanks for your useful comments and codes.
I tried both Rui's and Jim's codes.
Jim's codes gave an error as below:
"Error in substr(inputline, 1, begincol3 - 1) :
object 'inputline' not found"
I don't know what's wrong.
The Rui's codes worked correctly for the attached file. But I
Dear all;
I apologise, I didn't know that I have to cc the list.
Thank you Mr Rui for reminding me.
Let me clarify more.
I have no knowledge of the FORTRAN language. The text file that has been
attached is a model's output file and I know that the format is in FORTRAN.
I want to write a text file e
Background: there is a data file whose records, after a header,
can be describedby the Fortran format given in the header.
YES, you can easily read that file in R, and you don't even need to know
anything about Fortran formats to do it.
You can read the file as a data frame using read.table
using
You will have to define the variable
> >> names in your FORTRAN code and work out the input format
> >> specifications for the fields.
> >>
> >> Jim
> >>
> >> On Wed, Sep 21, 2022 at 8:30 PM Ebert,Timothy Aaron wrote:
> >> >
> >&
>> specifications for the fields.
>>
>> Jim
>>
>> On Wed, Sep 21, 2022 at 8:30 PM Ebert,Timothy Aaron wrote:
>> >
>> > This post was empty.
>> >
>> > Tim
>> >
>> > From: R-help On Behalf Of javad bayat
>> &
Javad,
It would help if you stopped calling it FORTRAN format. I doubt anyone
cares about names as compared to what kind of structure it holds.
It likely is some variant on a file commonly used in R such as one that
uses tabs or whitespace. It may have lines above with headers or comments
and you
Hello,
You forgot to cc the list.
Here is a solution, I believe the comments explain the several steps.
It's a matter to read in the file, separate the table from the rest,
update the 3rd column, assemble the pieces back together and write to file.
# this path depends on the OP's system
path
Dear Rasmus;
I have no knowledge of the FORTRAN language. The text file that has been
attached is a model's output file and I know that the format is in FORTRAN.
I want to write a text file exactly similar to the attached text file using
R programming.
The steps below explain my goal:
1- Read the t
Dear Javad,
Perhaps you were looking to read the
table in Air.txt (is this Fortran
format?) into R?
b <- readLines("Air.txt") # The text MIME attachment w/Mailman footer
...
b <- b[1:(which(b=="")-1)] # Remove the odd Mailman footer (at end of
df)
idx <- max(grep("^
Hello,
The attached file ends with R-Help's end message. This is unrelated to
computer languages, Fortran, R or other.
And there is no such thing as a Fortran format.
Can you please describe the problem you have?
Rui Barradas
Às 07:09 de 21/09/2022, javad bayat escreveu:
__
> Sent: Wednesday, September 21, 2022 2:09 AM
> To: R-help@r-project.org
> Subject: [R] Write text file in Fortran format
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To
This post was empty.
Tim
From: R-help On Behalf Of javad bayat
Sent: Wednesday, September 21, 2022 2:09 AM
To: R-help@r-project.org
Subject: [R] Write text file in Fortran format
[[alternative HTML version deleted]]
__
R-help@r-project.org
16 matches
Mail list logo