Dear Allin,
If it's interesting how I have found a way around
on Ubuntu, here is the script.
Riccardo told unambiguously such scripts are not
for official Gretl repo, so it's for my classes
(sure, everybody from the mail list can use it)
That's way I preferred to find a quick way for 
making plots.
Ironically, it has a decent right-click menu
that native R graphics window has not

Oleh

<hansl
# set shell_ok on via GUI on a Linux system
# R should have {forecast installed}

function matrix RforecastL (string mod "quoted R model command", list X "data 
series", int horizon[1::1], bool fplot[0] "whether to plot")
    bundle b = $sysinfo
    bos = b["os"]
    if (bos = "windows")&&(fplot = 1)
        funcerr "Please, use RforecastW on Windows"
    endif
    
    string text1 = $dotdir
    text0 = text1
    text1 = strsub(text1,"/","rumpelstiltskin")
    text1 = text1~"~1"
    sprintf h "%d", horizon
    sprintf pl "%d", fplot
    printf "\n"
    foreign language=R --send-data=X
                if (any(!class(gretldata)=="data.frame"))
                        {mts2frame2<-function(x) 
                                {ddd<-data.frame(x);
                                        if (length(class(x))>1)
                                {m<-ncol(x);for (i in 1:m) 
ddd[,i]<-ts(ddd[,i],start=start(x),\
                       frequency=frequency(x))}
                                        else
                                                
ddd[,1]<-ts(ddd[,1],start=start(x),frequency=frequency(x));
                         ddd};
                        gretldata<-mts2frame2(gretldata)}
                attach(gretldata);
                library(forecast);
                h<-(a)h;
                m1<-(a)mod;
                f1<-forecast(m1,h);
                pl<-(a)pl;
                if (pl==1)
                {
                zz<-as.character(@text1)[2]
                tt<-gsub("rumpelstiltskin", "/", zz,fixed=T);
                filename<-paste(tt,"/","Rplots.svg",sep="");
                library(graphics);
                library(grDevices);
                svg(filename);
                plot.forecast(f1)}
                print(f1);
                f2 <- cbind(f1$mean,f1$lower,f1$upper)
                
routput6789<-cbind(as.numeric(f2[,1]),as.numeric(f2[,2]),as.numeric(f2[,3]),\
           as.numeric(f2[,4]),as.numeric(f2[,5]))
                co <- capture.output(gretl.export(routput6789))
    end foreign
    if fplot = 1
        path = text0~"/Rplots.svg"
        shell
        launch xdg-open @path
    endif
    vars = mread("routput6789.mat",1)
    string path = $dotdir
    file1 = path~"/"~"routput6789.mat"
    r1 = remove(file1)
    return vars

end function

open denmark.gdt

list X = LRM LRY
RforecastL("ets(LRM)",X,4,1)
RforecastL("auto.arima(LRY)",X,4,1)
RforecastL("rwf(LRM)",X,4,1)

hansl>




















10 жовтня 2015, 04:05:11, від "Allin Cottrell" <cottrell(a)wfu.edu>:
 
>   On Sat, 10 Oct 2015, oleg_komashko(a)ukr.net wrote:
> 
> [...]
> 
> Thanks for the positive comments on gretl that I have ellipsized. 
> (But you're changing the thread topic once again!)
> 
> > [B]ut it's not proper if a GNU product can do less on Linux
> > [than it can do on MS Windows].
> 
> I can agree with that. Anything gretl can do on Windows it should be 
> able to do on Linux -- and also vice versa, since it seems that 
> (like it or not) most gretl users are still on Windows.
> 
> However, it seems to me that you just "got lucky" in being able to 
> produce plots via R, running under gretl's "foreign" apparatus on 
> Windows XP. I wouldn't expect this to work in general on any 
> platform -- it's seriously stretching what "foreign" can do, and I 
> would again suggest that you try a different approach, please!
> 
> (I'd also be interested to know if after this plotting episode on XP 
> you end up with zombie background processes running, as I did after 
> trying your hansl script on Fedora Linux: it "worked" insofar as it 
> put an R plot on screen, but it messed up the process table.)
> 
> Allin Cottrell
> _______________________________________________
> Gretl-users mailing list
> Gretl-users(a)lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users
 
 

Reply via email to