Title: | A Seamless Integration of 'Gretl' and 'R' |
---|---|
Description: | It allows running 'gretl' (<http://gretl.sourceforge.net/index.html>) program from R, R Markdown and Quarto. 'gretl' ('Gnu' Regression, 'Econometrics', and Time-series Library) is a statistical software for Econometric analysis. This package does not only integrate 'gretl' and 'R' but also serves as a 'gretl' Knit-Engine for 'knitr' package. Write all your 'gretl' commands in 'R', R Markdown chunk. |
Authors: | Sagiru Mati [aut, cre] |
Maintainer: | Sagiru Mati <[email protected]> |
License: | GPL |
Version: | 0.1.4 |
Built: | 2024-11-21 03:49:44 UTC |
Source: | https://github.com/sagirumati/gretlr |
It allows running 'gretl' (http://gretl.sourceforge.net/index.html) program from R, R Markdown and Quarto. 'gretl' ('Gnu' Regression, 'Econometrics', and Time-series Library) is a statistical software for Econometric analysis. This package does not only integrate 'gretl' and 'R' but also serves as a 'gretl' Knit-Engine for 'knitr' package. Write all your 'gretl' commands in 'R', R Markdown chunk.
Maintainer: Sagiru Mati [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/sagirumati/gretlR/issues
Other important functions:
eng_gretl()
,
exec_gretl()
,
exec_inp()
,
import_kable()
,
include_graph()
,
include_tex()
,
write_inp()
gretl
as knit-engine to knitr packageThis package runs on top of knitr to facilitate communication with gretl
. Run gretl
scripts from R, R Markdown and Quarto document.
eng_gretl(options)
eng_gretl(options)
options |
Chunk options, as provided by |
The gretl
engine can be activated via
knitr::knit_engines$set(gretl = gretlR::eng_gretl)
This will be set within an R Markdown document's setup chunk.
Set of gretl
(open-source software for Econometrics) codes
Sagiru Mati, ORCID: 0000-0003-1413-3974
Mati, Sagiru. 2020a. “DynareR: Bringing the Power of Dynare to R, R Markdown, and Quarto.” CRAN. https://CRAN.R-project.org/package=DynareR.
Mati, Sagiru. 2020b. EviewsR: A Seamless Integration of EViews and R. https://CRAN.R-project.org/package=EviewsR.
Mati, Sagiru. 2020c. gretlR: A Seamless Integration of Gretl and R. https://CRAN.R-project.org/package=gretlR.
Mati, Sagiru. 2023b. URooTab: Tabular Reporting of EViews Unit Root Tests. https://CRAN.R-project.org/package=URooTab.
Mati, Sagiru, Irfan Civcir, and S. I. Abba. 2023. “EviewsR: An r Package for Dynamic and Reproducible Research Using EViews, r, r Markdown and Quarto.” The R Journal 15 (2): 169–205. https://doi.org/10.32614/rj-2023-045.
Bob Rudis (2015).Running Go language chunks in R Markdown (Rmd) files. Available at: https://gist.github.com/hrbrmstr/9accf90e63d852337cb7
Yihui Xie (2019). knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.24.
Yihui Xie (2015) Dynamic Documents with R and knitr. 2nd edition. Chapman and Hall/CRC. ISBN 978-1498716963
Yihui Xie (2014) knitr: A Comprehensive Tool for Reproducible Research in R. In Victoria Stodden, Friedrich Leisch and Roger D. Peng, editors, Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595
Other important functions:
exec_gretl()
,
exec_inp()
,
gretlR
,
import_kable()
,
include_graph()
,
include_tex()
,
write_inp()
knitr::knit_engines$set(gretl = gretlR::eng_gretl) library(gretlR)
knitr::knit_engines$set(gretl = gretlR::eng_gretl) library(gretlR)
gretl
codes in RUse this function to Execute gretl
codes in R.
exec_gretl(code,path=basename(tempfile("gretlR")))
exec_gretl(code,path=basename(tempfile("gretlR")))
code |
Object or a character string representing the set of |
path |
Object or a character string representing the directory to execute the |
Set of gretl
(open-source software for Econometrics) outputs
Other important functions:
eng_gretl()
,
exec_inp()
,
gretlR
,
import_kable()
,
include_graph()
,
include_tex()
,
write_inp()
library(gretlR) ## Not run: code=r'(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" )' exec_gretl(code) ## End(Not run)
library(gretlR) ## Not run: code=r'(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" )' exec_gretl(code) ## End(Not run)
gretl
inp
file(s) in RUse this function to execute existing gretl
inp
file(s) in R
exec_inp(path=".")
exec_inp(path=".")
path |
Object or a character string representing the path(s) to the |
Set of gretl
(open-source software for Econometrics) outputs
Other important functions:
eng_gretl()
,
exec_gretl()
,
gretlR
,
import_kable()
,
include_graph()
,
include_tex()
,
write_inp()
library(gretlR) ## Not run: code=r'(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" )' write_inp(code,path="SomeFolder/gretlCodes") exec_inp("SomeFolder/gretlCodes") ## End(Not run)
library(gretlR) ## Not run: code=r'(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" )' write_inp(code,path="SomeFolder/gretlCodes") exec_inp("SomeFolder/gretlCodes") ## End(Not run)
kable
in R Markdown or Quarto document.Use this function to import file as kable
in R Markdown or Quarto document.
import_kable(path=".",chunk="",file="",start=NA,end=NA,skip_blank=TRUE, format=kable_format(),digits = getOption("digits"), row.names = NA,col.names = NA, align, caption = NULL, label = NULL, format.args = list(),escape = FALSE, table.attr = "", booktabs = TRUE, longtable = FALSE, valign = "t",position = "h", centering = TRUE, vline = getOption("knitr.table.vline",if (booktabs) "" else "|"), toprule = getOption("knitr.table.toprule", if (booktabs) "\\toprule" else "\\hline"), bottomrule = getOption("knitr.table.bottomrule", if (booktabs) "\\bottomrule" else "\\hline"), midrule = getOption("knitr.table.midrule", if (booktabs) "\\midrule" else "\\hline"), linesep = if (booktabs) c("","", "", "", "\\addlinespace") else "\\hline", caption.short = "",table.envir = if (!is.null(caption)) "table",...)
import_kable(path=".",chunk="",file="",start=NA,end=NA,skip_blank=TRUE, format=kable_format(),digits = getOption("digits"), row.names = NA,col.names = NA, align, caption = NULL, label = NULL, format.args = list(),escape = FALSE, table.attr = "", booktabs = TRUE, longtable = FALSE, valign = "t",position = "h", centering = TRUE, vline = getOption("knitr.table.vline",if (booktabs) "" else "|"), toprule = getOption("knitr.table.toprule", if (booktabs) "\\toprule" else "\\hline"), bottomrule = getOption("knitr.table.bottomrule", if (booktabs) "\\bottomrule" else "\\hline"), midrule = getOption("knitr.table.midrule", if (booktabs) "\\midrule" else "\\hline"), linesep = if (booktabs) c("","", "", "", "\\addlinespace") else "\\hline", caption.short = "",table.envir = if (!is.null(caption)) "table",...)
path |
Object or a character string representing the path(s) to the |
chunk |
Name of the |
file |
Name of a file to be imported as |
start |
Numeric. The start line of the |
end |
Numeric. The last line of the |
skip_blank |
Logical. Whether or not to include blank rows. |
format |
A character string. Possible values are |
digits |
Maximum number of digits for numeric columns, passed to
|
row.names |
Logical: whether to include row names. By default, row names
are included if |
col.names |
A character vector of column names to be used in the table. |
align |
Column alignment: a character vector consisting of |
caption |
The table caption. |
label |
The table reference label. By default, the label is obtained
from |
format.args |
A list of arguments to be passed to |
escape |
Boolean; whether to escape special characters when producing
HTML or LaTeX tables. When |
table.attr |
A character string for addition HTML table attributes. This is convenient if you simply want to add a few HTML classes or styles. For example, you can put 'class="table" style="color: red"'. |
booktabs |
T/F for whether to enable the booktabs format for tables. I personally would recommend you turn this on for every latex table except some special cases. |
longtable |
T/F for whether to use the longtable format. If you have a table that will span over two or more pages, you will have to turn this on. |
valign |
You probably won't need to adjust this latex option very often.
If you are familar with latex tables, this is the optional position for the
tabular environment controling the vertical position of the table relative
to the baseline of the surrounding text. Possible choices are |
position |
This is the "real" or say floating position for the latex
table environment. The |
centering |
T (default)/F. Whether to center tables in the table environment. |
vline |
vertical separator. Default is nothing for booktabs tables but "|" for normal tables. |
toprule |
toprule. Default is hline for normal table but toprule for booktabs tables. |
bottomrule |
bottomrule. Default is hline for normal table but bottomrule for booktabs tables. |
midrule |
midrule. Default is hline for normal table but midrule for booktabs tables. |
linesep |
By default, in booktabs tables, |
caption.short |
Another latex feature. Short captions for tables |
table.envir |
You probably don't need to change this as well. The default setting is to put a table environment outside of tabular if a caption is provided. |
... |
Other arguments (see Examples and References). |
kable
Other important functions:
eng_gretl()
,
exec_gretl()
,
exec_inp()
,
gretlR
,
include_graph()
,
include_tex()
,
write_inp()
library(gretlR) ## Not run: code=r'(nulldata 500 set seed 13 gretl1 = normal() gretl2 = normal() setobs 12 1980:01 --time-series ols gretl1 const gretl2 tabprint --output="olsTable.csv")' exec_gretl(code=code,path='gretlR/Table/gretlCode') # this creates 'gretlR/Table' folder import_kable(chunk = "Table",file = "olsTable.csv",format="pandoc",caption="Table generated from gretl chunk", start=3,end=7,digits=2) # Alternatively, use the absolute/relative path to the file import_kable(path = "gretlR/Table/olsTable.csv",format="pandoc",caption="Table generated from path", start=3,end=7,digits=2) ## End(Not run)
library(gretlR) ## Not run: code=r'(nulldata 500 set seed 13 gretl1 = normal() gretl2 = normal() setobs 12 1980:01 --time-series ols gretl1 const gretl2 tabprint --output="olsTable.csv")' exec_gretl(code=code,path='gretlR/Table/gretlCode') # this creates 'gretlR/Table' folder import_kable(chunk = "Table",file = "olsTable.csv",format="pandoc",caption="Table generated from gretl chunk", start=3,end=7,digits=2) # Alternatively, use the absolute/relative path to the file import_kable(path = "gretlR/Table/olsTable.csv",format="pandoc",caption="Table generated from path", start=3,end=7,digits=2) ## End(Not run)
Use this function to include graph file in R Markdown or Quarto document.
include_graph(path=".",chunk="",graph="")
include_graph(path=".",chunk="",graph="")
path |
Object or a character string representing the path(s) to the |
chunk |
Name of the |
graph |
Name of the graph and its extension |
Set of gretl
(open-source software for Econometrics) outputs
Other important functions:
eng_gretl()
,
exec_gretl()
,
exec_inp()
,
gretlR
,
import_kable()
,
include_tex()
,
write_inp()
library(gretlR) ## Not run: code=r'(nulldata 500 set seed 13 gretl1 = normal() gretl2 = normal() setobs 12 1980:01 --time-series gnuplot gretl1 --time-series --with-lines --output="line.png" )' exec_gretl(code) include_graph(path="line.png") ## End(Not run)
library(gretlR) ## Not run: code=r'(nulldata 500 set seed 13 gretl1 = normal() gretl2 = normal() setobs 12 1980:01 --time-series gnuplot gretl1 --time-series --with-lines --output="line.png" )' exec_gretl(code) include_graph(path="line.png") ## End(Not run)
Use this function to include TeX file in R Markdown or Quarto document.
include_tex(path=".",chunk="",tex="",start=NA,end=NA)
include_tex(path=".",chunk="",tex="",start=NA,end=NA)
path |
Object or a character string representing the path(s) to the |
chunk |
Name of the |
tex |
Name of a |
start |
Numeric. The start line of the |
end |
Numeric. The last line of the |
Set of gretl
(open-source software for Econometrics) outputs
Other important functions:
eng_gretl()
,
exec_gretl()
,
exec_inp()
,
gretlR
,
import_kable()
,
include_graph()
,
write_inp()
library(gretlR) ## Not run: code=r'(nulldata 500 set seed 13 gretl1 = normal() gretl2 = normal() setobs 12 1980:01 --time-series ols gretl1 const gretl2 tabprint --output="olsTable.tex")' exec_gretl(code=code,path='gretlR/TeXFolder/gretlCode') include_tex(chunk="TeXFolder",tex="olsTable") # Alternatively, use the absolute/relative path to the TeX file include_tex("gretlR/TeXFolder/olsTable.tex") ## End(Not run)
library(gretlR) ## Not run: code=r'(nulldata 500 set seed 13 gretl1 = normal() gretl2 = normal() setobs 12 1980:01 --time-series ols gretl1 const gretl2 tabprint --output="olsTable.tex")' exec_gretl(code=code,path='gretlR/TeXFolder/gretlCode') include_tex(chunk="TeXFolder",tex="olsTable") # Alternatively, use the absolute/relative path to the TeX file include_tex("gretlR/TeXFolder/olsTable.tex") ## End(Not run)
gretl
inp
file in RUse this function to write gretl
inp
file in R
write_inp(code,path)
write_inp(code,path)
code |
Object or a character string representing the set of |
path |
Object or a character string representing the path to write the |
Set of gretl
(open-source software for Econometrics) outputs
Other important functions:
eng_gretl()
,
exec_gretl()
,
exec_inp()
,
gretlR
,
import_kable()
,
include_graph()
,
include_tex()
library(gretlR) ## Not run: code=r'(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" )' write_inp(code,path="gretlCodes") ## End(Not run)
library(gretlR) ## Not run: code=r'(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" )' write_inp(code,path="gretlCodes") ## End(Not run)