Skip to content

Creation of text files for use with UCODE_2005

3 messages · Jesse Robinson, R. Michael Weylandt, William Dunlap

#
Hello, 

I'm new to R-help, although I am a frequent user of its resources. I am
using the package REACTRAN to run some relatively simple transport modeling
(which we hope will evolve greater functionality over time). I would like to
optimize model parameters to match observed field data, and am interested in
using UCODE_2005 for this, which our lab has previously used to great
success. 

The problem: creating the template and input files from R poses difficulty,
as the position of elements (strings, numerics, observation data and labels)
have to be exact in terms of spacing and width. Is there a package or
resource available that can help printing instruction files that simplify
this? You can imagine that if 5 spaces were required between variables in
rows, then 7 between the next, then 9, etc. this would be challenging.
Example (pasting here distorts space width):

jtf !                                        # FREE FORMAT
5.1  2.7  50.                                # HeadLeft HeadRight
WidthOfModel
!K                  ! !w                  !  # UCODE will Substitute K and W
with many signigifcant figures

Thanks very much for any suggestions!
Jesse







--
View this message in context: http://r.789695.n4.nabble.com/Creation-of-text-files-for-use-with-UCODE-2005-tp4643151.html
Sent from the R help mailing list archive at Nabble.com.
#
On Fri, Sep 14, 2012 at 4:33 PM, Jesse Robinson <jrobin02 at syr.edu> wrote:
Have you come across the write.fwf() function before? It might make
that much easier.

Cheers,
Michael
#
Have you looked at the sprintf function?  E.g.,
N:    3.14    STATE:Ohio <eol>
N:   31.40    STATE:Oklahoma <eol>
N:  314.00    STATE:Oregon <eol>
N: 3140.00    STATE:Pennsylv <eol>
N:31400.00    STATE:Rhode Is <eol>
N:3.14        STATE:Ohio     <eol>
N:31.40       STATE:Oklahoma <eol>
N:314.00      STATE:Oregon   <eol>
N:3140.00     STATE:Pennsylv <eol>
N:31400.00    STATE:Rhode Is <eol>
N:00003.14    STATE:    Ohio <eol>
N:00031.40    STATE:Oklahoma <eol>
N:00314.00    STATE:  Oregon <eol>
N:03140.00    STATE:Pennsylv <eol>
N:31400.00    STATE:Rhode Is <eol>

(View with a fixed-width font to see the spacing properly.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com