Hi Robert,
I also do a lot of this ... particularly for QA documentation. What I normally
do is export the table to Excel using the Tara addon and use that for the other
documents. It's quite simple and its also in the labs. Note, the tara addon is
not part of the standard J documentation, you should add it using the
Run->Package Manager menu.
NB. So first lets load the tara addon
load jpath '~addons/tables/tara/tara.ijs'
NB. Setup the data to be written
[captions=. ('AGE'; 'PR'; 'M'; 'Catch WAA'; 'Pop WAA'; '% Mat at Age')
+---+--+-+---------+-------+------------+
|AGE|PR|M|Catch WAA|Pop WAA|% Mat at Age|
+---+--+-+---------+-------+------------+
captions,< every |:>age; pr; m; caa_waa; pop_waa; per_mat
+---+-----+---+---------+-------+------------+
|AGE|PR |M |Catch WAA|Pop WAA|% Mat at Age|
+---+-----+---+---------+-------+------------+
|2 |0.474|0.2|0.766 |0.766 |0 |
+---+-----+---+---------+-------+------------+
|3 |0.632|0.2|1.017 |1.017 |0 |
+---+-----+---+---------+-------+------------+
|4 |0.737|0.2|1.727 |1.727 |0.25 |
+---+-----+---+---------+-------+------------+
|5 |0.895|0.2|2.514 |2.514 |0.5 |
+---+-----+---+---------+-------+------------+
|6 |0.947|0.2|3.287 |3.287 |0.75 |
+---+-----+---+---------+-------+------------+
|7 |0.947|0.2|3.994 |3.994 |1 |
+---+-----+---+---------+-------+------------+
|8 |1 |0.2|4.806 |4.806 |1 |
+---+-----+---+---------+-------+------------+
|9 |1 |0.2|5.607 |5.607 |1 |
+---+-----+---+---------+-------+------------+
|10 |1 |0.2|6.481 |6.481 |1 |
+---+-----+---+---------+-------+------------+
|11 |1 |0.2|8.046 |8.046 |1 |
+---+-----+---+---------+-------+------------+
NB. Save to excel worksheet1
(captions,< every |:>age; pr; m; caa_waa; pop_waa; per_mat) writexlsheets
'c:\test.xls'
1
Now open the file: 'C:\TEST.xls' and copy and paste is to any document. :)
I suggest that you do the Tara Lab so that you can read xls files (there is a
new addon that can read the 2007 format excel) and write to multiple worksheets.
r/Alex
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Robert O'Boyle
Sent: Thursday, August 06, 2009 8:22 PM
To: [email protected]
Subject: [Jprogramming] Outputing tables
I have J tables which I would like to place into various documents (e.g.
WORD). Here is an example
pr =: 0.474 0.632 0.737 0.895 0.947 0.947 1 1 1 1
age=: 2 3 4 5 6 7 8 9 10 11
m=: 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2
pop_waa =: 0.766 1.017 1.727 2.514 3.287 3.994 4.806 5.607
6.481 8.046
caa_waa =: 0.766 1.017 1.727 2.514 3.287 3.994 4.806 5.607
6.481 8.046
per_mat=: 0 0 0.25 0.5 0.75 1 1 1 1 1
in_data=: ('AGE'; 'PR'; 'M'; 'Catch WAA'; 'Pop WAA'; '% Mat at
Age'),:(,. age);(8j3":,.pr);(8j3":,.($pr)$m) ; (8j3":,.caa_waa);
(8j3":,.pop_waa) ; (8j3":,.per_mat)
I'd like to be able to directly copy in_data into a document. How can I do
this in J?
I routinely move data back & forth between EXCEL and J. Here, it's the
formatted table that I am interested in moving.
Thanks
Bob
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm