Skip to content

Output Data Formatting Question

2 messages · Jason Rupert, jim holtman

#
Within R I need to reformat my data so that the output looks like the following:
" 7 WORDS              5550         3.14159         -6.           6."

Previous folks were doing this by hand, but I would like to have a formula do it. 


That is, 
(a) 7 (place holder) on second column, then a space, 
(b) WORDS (placeholder) is a string descriptor that is left justified to column 4, 
(c) 5550 (place hoder) is right justified to column 26, 
(d) 3.14159 (place holder) is right justified to column 41, 
(e) -6. (place holder) is right justified to column 53, and
(f) 6. (place holder) is right justified to column 66. 

The basic sprintf commands did not seem like they would get me there, nor did the "paste" capability. 

After getting the data into that format I plan to use "write" to place the data in an output *.txt file. 

Thank you for any hints and tips that can be provided.
#
I don't know why sprintf does not work for you.  Here is something
close; you will have to work on the spacing but the formating in
sprintf lets you specify the field size:
[1] " 7 WORD                  5550       3.14158"

        
On Fri, Mar 13, 2009 at 4:48 PM, Jason Rupert <jasonkrupert at yahoo.com> wrote: