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.
Creation of text files for use with UCODE_2005
3 messages · Jesse Robinson, R. Michael Weylandt, William Dunlap
On Fri, Sep 14, 2012 at 4:33 PM, Jesse Robinson <jrobin02 at syr.edu> wrote:
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.
Have you come across the write.fwf() function before? It might make that much easier. Cheers, Michael
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.
______________________________________________ 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.
Have you looked at the sprintf function? E.g.,
n <- 3.14 * 10^(0:4)
x <- state.name[35:39]
cat(sprintf("N:%8.2f STATE:%0.8s <eol>\n", n, x), sep="")
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>
cat(sprintf("N:%-8.2f STATE:%-8.8s <eol>\n", n, x), sep="")
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>
cat(sprintf("N:%08.2f STATE:%8.8s <eol>\n", n, x), sep="")
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
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Jesse Robinson Sent: Friday, September 14, 2012 8:34 AM To: r-help at r-project.org Subject: [R] Creation of text files for use with UCODE_2005 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.
______________________________________________ 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.