gretlR is an R package that can run gretl
program from R Markdown.
gretlR can be installed using the following commands in R.
Please load the gretlR package as follows:
```{r gretlR}
library(gretlR)
```
Then create a chunk for gretl
as shown below:
```{gretl gretlR1,eval=T,echo=T,comment=NULL,results='hide'}
nulldata 500
set seed 13
gretl1 = normal()
gretl2 = normal()
setobs 12 1980:01 --time-series
gnuplot gretl1 --time-series --with-lines --output="line.png"
gnuplot gretl2 gretl1 --output="scatter.png"
ols gretl1 const gretl2
modeltab add
tabprint --output="ols.Rmd"
eqnprint --output="olsmodel.Rmd"
tabprint --output="ols.csv"
```
The above chunk creates an gretl program with the chunk’s content, then automatically gretl, which will save gretl outputs in the current directory.
We can dynamically and reproducibly fetch the gretl
graph object we created with the gretl
chunk using the following R chunk:
For the scatter graph:
or the line graph:
we can also include the equation of the OLS generated by the gretl
chunk using the following R chunk;
Remember the OLS equation output is saved by the gretl
chunk as olsmodel.Rmd
. The entire OLS equation model:
```{r child, child='olsmodel.Rmd'}
```
Remember the OLS table output is saved by gretl
chunk as ols.Rmd
. The entire OLS table output:
```{r child1,child="ols.Rmd"}
```
Unfortunately, user of gretl
has little or no control over the outputs customisation before exporting.
Please visit my Github for a better explanation and example files.