On 07/05/13 19:29, Allin Cottrell wrote:
This is partly in response to something Ignacio asked for a 
while ago, namely the ability to produce within a function 
package, plots that are usually only available via GUI means.
Thanks for your attention ;-))

What I have in CVS is just at the proof of concept stage, but 
here's the concept:

1) Parallel to certain commands, we offer a function that 
returns the information needed to produce a plot, in the form 
of a bundle. In this bundle we record the name of the built-in 
function that produced it.

2) We provide a built-in function (or maybe eventually a 
command) that produces a plot from such a bundle: it checks 
for the creator of the bundle and hands off to the appropriate 
specialized plotting function.

Right now this is (partially) implemented for the irf() 
function. Until now this function has returned a matrix, but 
in CVS it returns a bundle which contains the matrix along 
with the additional info needed for the plot (e.g. the names 
of the target and shock variables and the "alpha" for the 
confidence interval, if any).

Isn't this backward incompatible? Actually, no. You can still 
assign from the irf() function to a matrix. That's because 
I've added a special bundle key: if you add a matrix to a 
bundle under the name "payload_matrix", then the following 
sort of thing (a "cast" from bundle to matrix) will work:

bundle b
b["payload_matrix"] = I(3)
b["otherthing"] = "hello"
matrix m = b

Here's an example of the whole deal:

open data9-7
# assign from irf() to bundle
bundle b = irf(1, 2, 0.2)
bplot(b, "display")
# we can still assign from irf() to matrix
matrix m = irf(1, 2, 0.2)

Umm...  I am not sure I am understanding all this subject.
The idea is that bplot() is the function/command which takes out the plot, right?
(I am not seeing now it does anything)
Can it run from a function?

The second (string) argument to bplot() is currently just a 
dummy and is ignored. The idea is that you should be able to 
use it to specify the format/destination of the plot but 
that's not wired up yet.
this is as the --output=XX option in 'gnuplot', I think.

The reason I say "bplot" (or whatever we decide to name it) 
should perhaps be a command rather than a function is that
then one could direct it to a GUI object if desired, as in

graph1 <- bplot bundle
good idea.

(Or I guess we could use a --bundle=foo option with the 
existing "gnuplot" command, though maybe it's already 
overburdened with options.)

In relation to Ignacio's request, we could add corrgm() and 
pergm() functions that return bundles, and add support for 
plotting from such bundles.

OK. I will test it with some of my packages, when available.

Firma Arista
Ignacio Díaz-Emparanza
94 6013732

Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013740 | F.: +34 946013754
ERNE! Baliteke mezu honen zatiren bat edo mezu osoa legez babestuta egotea. Mezuak badu bere hartzailea. Okerreko helbidera heldu bada (helbidea gaizki idatzi, transmisioak huts egin) eman abisu igorleari, korreo honi erantzunda. Kontuz! Mezua ez bada zuretzat, ez erabili, ez zabaldu beste inori, ez kopiatu eta ez baliatu.
¡ATENCIÓN! Este mensaje contiene información privilegiada o confidencial a la que sólo tiene derecho a acceder el destinatario. Si usted lo recibe por error le agradeceríamos que no hiciera uso de la información y que se pusiese en contacto con el remitente.

E-mail hau inprimatu baino lehen egiaztatu inprimatzeko beharra.
Antes de imprimir este e-mail piense bien si es necesario hacerlo.