**Thank you for using EviewsR!**
To acknowledge our work, please cite the package:
                        PLAIN TEXT:
1.  Mati S. (2020). EviewsR: A Seamless Integration of EViews and R.
    CRAN. 
Figure 7.1: EViews graphs imported automatically by fig-EviewsR chunk
The above chunk creates an Eviews program with the chunk’s content, then automatically open Eviews and run the program, which will create an Eviews workfile with pages containing monthly sample from 2000 to 2022. The program will also save an EViews workfile named `EviewsR_workfile` in the current directory. The `eviews` chunk automatically returns the outputs of each equation object as a dataframe, accessible via `chunkLabel$pageName_equationName`. For example, The *R*2 of the `ols` equation object is 0.044951, which can be accessed using `` `r knitr::inline_expr('EviewsR$eviewsrpage_ols$r2')` ``. We can obtain the table object by `chunkLabel$pageName_tableName`. Therefore, `EviewsR$eviewsrpage_olstable` will give us the `OLSTable` object as dataframe. Note the underscore (`_`) between the `pageName` and `equationName`, and between the `pageName` and `tableName`. EviewsR$eviewsrpage_ols$r2 #> [1] 0.044951 EviewsR$eviewsrpage_ols$aic #> [1] 4.310163 K = EviewsR$eviewsrpage_olstable[c(6, 8, 9), 1:5] colnames(K) = NULL knitr::kable(K, row.names = F, caption = "Selected cells of EViews table object")| Variable | Coefficient | Std. Error | t-Statistic | Prob. | 
| C | -0.301413 | 0.260956 | -1.155033 | 0.2491 | 
| X | -0.051410 | 0.014316 | -3.591137 | 0.0004 | 

Figure 7.2: Graphs of existing EViews series objects imported by fig-eviewsGraph chunk
We can also create graph objects from an R dataframe Data = data.frame(x = cumsum(rnorm(100)), y = cumsum(rnorm(100))) eviews_graph(series = Data, group = TRUE, start_date = "1990Q4", frequency = "Q")
Figure 7.3: Graphs of an R dataframe imported by fig-eviewsGraph1 chunk
To plot a scatter graph and histogram on the same frame: eviews_graph(wf = "EviewsR_workfile", page = "EviewsRPage", series = "x y", group = T, graph_command = "scat(ab=histogram) linefit()", mode = "overwrite", graph_procs = "setelem(1) lcolor(green) lwidth(2)")
Figure 7.4: Scatter graph along with histogram
### 7.2.3 The eviews\_import() function Data can be imported from external sources by `eviews_import()` function. eviews_import(source_description = "eviews_import.csv", start_date = "1990", frequency = "m", rename_string = "x ab", smpl_string = "1990m10 1992m10") Alternatively, use the dataframe as the `source_description`. eviews_import(source_description = Data, wf = "eviews_import1", start_date = "1990", frequency = "m", rename_string = "x ab", smpl_string = "1990m10 1992m10") ### 7.2.4 The eviews\_pagesave() function Similar to Eviews workfile, an Eviews page can be saved in various formats by `eviews_pagesave()` function. eviews_pagesave(wf = "eviewsr_workfile", page = "EviewsRPage", source_description = "pagesave.csv", drop_list = "y") ### 7.2.5 The eviews\_wfcreate() function An Eviews workfile can be created using `eviews_wfcreate()` function in R. eviews_wfcreate(wf = "eviews_wfcreate", page = "EviewsRPage", frequency = "m", start_date = "1990", end_date = "2022") Create a workfile from a dataframe eviews_wfcreate(source_description = Data, wf = "eviews_wfcreate1", page = "EviewsR_page", frequency = "m", start_date = "1990") ### 7.2.6 The eviews\_wfsave() function An EViews workfile can be saved various output formats using `eviews_wfsave()` in function in R. eviews_wfsave(wf = "eviewsr_workfile", source_description = "wfsave.csv") ### 7.2.7 The exec\_commands() function A set of Eviews commands can be executed with the help of `exec_commands()` function in R. exec_commands(c("wfcreate(wf=exec_commands,page=eviewsPage) m 2000 2022")) eviewsCommands = "pagecreate(page=eviewspage1) 7 2020 2022 for %page eviewspage eviewspage1 pageselect {%page} genr y=@cumsum(nrnd) genr x=@cumsum(nrnd) equation ols.ls y c x graph x_graph.line x graph y_graph.area y freeze(OLSTable,mode=overwrite) ols next" exec_commands(commands = eviewsCommands, wf = "exec_commands") ### 7.2.8 The export\_dataframe() function Use `export_dataframe()` function to export dataframe object to Eviews. export_dataframe(wf = "export_dataframe", source_description = Data, start_date = "1990", frequency = "m") ### 7.2.9 The import\_equation() function Import EViews equation data members into R, R Markdown or Quarto. import_equation(wf = "EviewsR_workfile", page = "EviewsRPage", equation = "OLS") To access the imported equation in base R: ### 7.2.10 The import\_graph() function Import EViews graph objects(s) into R, R Markdown or Quarto. import_graph(wf = "eviewsr_workfile")
Figure 7.5: EViews graphs imported using import\_graph() function
To import only graphs that begin with x: import_graph(wf = "exec_commands", graph = "x*")
Figure 7.6: EViews graphs that begin with X imported using import\_graph() function
### 7.2.11 The import\_kable() function Eviews tables can be imported as `kable` object by `import_kable()` function. Therefore, we can include the import_kable(wf = "EViewsR_workfile", page = "EviewsRPage", table = "OLSTable", format = "html", caption = "Selected cells of EViews table imported using import_kable() function", range = "r7c1:r10c5", digits = 3)| Variable | Coefficient | Std. Error | t-Statistic | Prob. | 
|---|---|---|---|---|
| C | -0.301 | 0.261 | -1.155 | 0.249 | 
| X | -0.051 | 0.014 | -3.591 | 0.000 | 

Figure 7.7: EViews graphs automatically imported by import\_workfile() function
To import specific objects import_workfile(wf = "exec_commands", equation = "ols", graph = "x*", series = "y*", table = "ols*") To import objects on specific page(s) import_workfile(wf = "exec_commands", page = "eviewspage eviewspage1") To access the objects in base R: eviews$eviewspage_ols # equation # eviewspage-x_graph # graph saved in 'figure/' folder eviews$eviewspage %>% head() # series eviews$eviewspage_olstable # table ### 7.2.15 The rwalk() function A set of random walk series can be simulated in R using EViews engine, thanks to `rwalk()` function. rwalk(wf = "eviewsr_workfile", series = "X Y Z", page = "", rndseed = 12345, frequency = "M", num_observations = 100, class = "xts") xts::plot.xts(rwalk$xyz, type = "l", main = "") ggplot2::autoplot(rwalk$xyz)
Figure 7.8: Plots of imported EViews random walk series objects
### 7.2.16 Demo The demo files are included and can be accessed via `demo(package="EviewsR")` demo(create_object()) demo(eviews_graph()) demo(eviews_import()) demo(eviews_pagesave()) demo(eviews_wfcreate()) demo(eviews_wfsave()) demo(exec_commands()) demo(export_dataframe()) demo(import_equation()) demo(import_graph()) demo(import_kable()) demo(import_series()) demo(import_table()) demo(import_workfile()) demo(rwalk()) demo(set_eviews_path()) # 8 Template Template for R Markdown is created. Go to `file->New File->R Markdown-> From Template->EviewsR`. # 9 Similar Packages You might be interested in the following packages: - [DynareR](https://github.com/sagirumati/DynareR): DynareR: Bringing the Power of Dynare to R, R Markdown, and Quarto - [gretlR](https://github.com/sagirumati/gretlR): A Seamless Integration of gretl and R. - [URooTab](https://github.com/sagirumati/URooTab): A Seamless Integration of gretl and R.